{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6edd5547",
   "metadata": {},
   "source": [
    "# 6-2,训练模型的3种方法\n",
    "\n",
    "Pytorch通常需要用户编写自定义训练循环，训练循环的代码风格因人而异。\n",
    "\n",
    "有3类典型的训练循环代码风格：脚本形式训练循环，函数形式训练循环，类形式训练循环。\n",
    "\n",
    "下面以minist数据集的多分类模型的训练为例，演示这3种训练模型的风格。\n",
    "\n",
    "其中类形式训练循环我们同时演示torchkeras.KerasModel和torchkeras.LightModel两种示范。\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "02dff65a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "24b101ed",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.__version__ =  2.0.1\n",
      "torchkeras.__version__ =  3.9.3\n"
     ]
    }
   ],
   "source": [
    "import torch \n",
    "import torchkeras\n",
    "print(\"torch.__version__ = \", torch.__version__)\n",
    "print(\"torchkeras.__version__ = \", torchkeras.__version__) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b143f46a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "52642b45",
   "metadata": {},
   "source": [
    "### 〇，准备数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "04d2d65b",
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch \n",
    "from torch import nn \n",
    "\n",
    "import torchvision \n",
    "from torchvision import transforms\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5fa1c7d4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "60000\n",
      "10000\n"
     ]
    }
   ],
   "source": [
    "transform = transforms.Compose([transforms.ToTensor()])\n",
    "\n",
    "ds_train = torchvision.datasets.MNIST(root=\"./data/mnist/\",train=True,download=True,transform=transform)\n",
    "ds_val = torchvision.datasets.MNIST(root=\"./data/mnist/\",train=False,download=True,transform=transform)\n",
    "\n",
    "dl_train =  torch.utils.data.DataLoader(ds_train, batch_size=128, shuffle=True, num_workers=4)\n",
    "dl_val =  torch.utils.data.DataLoader(ds_val, batch_size=128, shuffle=False, num_workers=4)\n",
    "\n",
    "print(len(ds_train))\n",
    "print(len(ds_val))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f7130d4e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"463.452941pt\" height=\"476.538125pt\" viewBox=\"0 0 463.452941 476.538125\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2023-08-02T17:02:27.116950</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.6.2, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 476.538125 \n",
       "L 463.452941 476.538125 \n",
       "L 463.452941 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 10.7 152.765184 \n",
       "L 141.147059 152.765184 \n",
       "L 141.147059 22.318125 \n",
       "L 10.7 22.318125 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g clip-path=\"url(#p050aa697bb)\">\n",
       "    <image xlink:href=\"data:image/png;base64,\n",
       "iVBORw0KGgoAAAANSUhEUgAAALYAAAC2CAYAAAB08HcEAAAF7UlEQVR4nO3dX2iVdRzH8edxR52r5VrLnIRzbbWZ1gaOmjlWkJkXIkjG2kXBoqLERrXoQgIrihz9AYlaIIQGA01DEPpzZ0PIbMMotD+jrUXTdWQbW6bDubPTVXff7+Zzdnbm+fh+XX5//HYe8M3v4sc5j+H6cGsyAMTMm+sHAGYDYUMSYUMSYUMSYUMSYUMSYUMSYUMSYUMSYUMSYUMSYUMSYUMSYUMSYUMSYUMSYUMSYUMSYUNSLFMf1N12jz3f3JbWz/lwpMyc7+7Y4O4JE6E5r3zzD3dPIn4u2oMhozixIYmwIYmwIYmwIYmwISnM1Jugxh+usecvDrt7dpR/ac43LLqQlmeaTjwx5q7VH2kx55Wv/uruSYyMzviZcGU4sSGJsCGJsCGJsCGJsCGJsCEpY9d9qYgVLzXnw59c5+55rrTDnDfmx9PyTNPZfqbOXTvZVm3Oiw6dcvdMnj8/00e6JnFiQxJhQxJhQxJhQxJhQ9JVfSuSitiK5eZ8dE2xu6fhja/N+bMFvWl5pum0DNS6a8c/sr88Vrj3e/8PTiZm+khZjxMbkggbkggbkggbkggbkggbkuSu+1IRKy0x5z1Ny9w9rzXsN+ePXD+Ylmeazo64fQ0YBEHQsdu+Prxx3/HZepyrDic2JBE2JBE2JBE2JBE2JHErkqKwZrU5725e4O7Zs26fOa/PHU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jzRN6ku6ek7Jw5z9sWunv+ft/+ktjJGv+WZzBh3wzde7DF3VP+UipfBIuOExuSCBuSCBuSCBuSCBuSCBuSuO6DJE5sSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSCJsSPoPboXuOT7HWnMAAAAASUVORK5CYII=\" id=\"imagee38946d0ec\" transform=\"scale(1 -1) translate(0 -131.04)\" x=\"10.7\" y=\"-21.725184\" width=\"131.04\" height=\"131.04\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\"/>\n",
       "   <g id=\"matplotlib.axis_2\"/>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 10.7 152.765184 \n",
       "L 10.7 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 141.147059 152.765184 \n",
       "L 141.147059 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 10.7 152.765184 \n",
       "L 141.147059 152.765184 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 10.7 22.318125 \n",
       "L 141.147059 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_1\">\n",
       "    <!-- label = 5 -->\n",
       "    <g transform=\"translate(48.752904 16.318125) scale(0.12 -0.12)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-6c\" d=\"M 603 4863 \n",
       "L 1178 4863 \n",
       "L 1178 0 \n",
       "L 603 0 \n",
       "L 603 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-61\" d=\"M 2194 1759 \n",
       "Q 1497 1759 1228 1600 \n",
       "Q 959 1441 959 1056 \n",
       "Q 959 750 1161 570 \n",
       "Q 1363 391 1709 391 \n",
       "Q 2188 391 2477 730 \n",
       "Q 2766 1069 2766 1631 \n",
       "L 2766 1759 \n",
       "L 2194 1759 \n",
       "z\n",
       "M 3341 1997 \n",
       "L 3341 0 \n",
       "L 2766 0 \n",
       "L 2766 531 \n",
       "Q 2569 213 2275 61 \n",
       "Q 1981 -91 1556 -91 \n",
       "Q 1019 -91 701 211 \n",
       "Q 384 513 384 1019 \n",
       "Q 384 1609 779 1909 \n",
       "Q 1175 2209 1959 2209 \n",
       "L 2766 2209 \n",
       "L 2766 2266 \n",
       "Q 2766 2663 2505 2880 \n",
       "Q 2244 3097 1772 3097 \n",
       "Q 1472 3097 1187 3025 \n",
       "Q 903 2953 641 2809 \n",
       "L 641 3341 \n",
       "Q 956 3463 1253 3523 \n",
       "Q 1550 3584 1831 3584 \n",
       "Q 2591 3584 2966 3190 \n",
       "Q 3341 2797 3341 1997 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-62\" d=\"M 3116 1747 \n",
       "Q 3116 2381 2855 2742 \n",
       "Q 2594 3103 2138 3103 \n",
       "Q 1681 3103 1420 2742 \n",
       "Q 1159 2381 1159 1747 \n",
       "Q 1159 1113 1420 752 \n",
       "Q 1681 391 2138 391 \n",
       "Q 2594 391 2855 752 \n",
       "Q 3116 1113 3116 1747 \n",
       "z\n",
       "M 1159 2969 \n",
       "Q 1341 3281 1617 3432 \n",
       "Q 1894 3584 2278 3584 \n",
       "Q 2916 3584 3314 3078 \n",
       "Q 3713 2572 3713 1747 \n",
       "Q 3713 922 3314 415 \n",
       "Q 2916 -91 2278 -91 \n",
       "Q 1894 -91 1617 61 \n",
       "Q 1341 213 1159 525 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 4863 \n",
       "L 1159 4863 \n",
       "L 1159 2969 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-65\" d=\"M 3597 1894 \n",
       "L 3597 1613 \n",
       "L 953 1613 \n",
       "Q 991 1019 1311 708 \n",
       "Q 1631 397 2203 397 \n",
       "Q 2534 397 2845 478 \n",
       "Q 3156 559 3463 722 \n",
       "L 3463 178 \n",
       "Q 3153 47 2828 -22 \n",
       "Q 2503 -91 2169 -91 \n",
       "Q 1331 -91 842 396 \n",
       "Q 353 884 353 1716 \n",
       "Q 353 2575 817 3079 \n",
       "Q 1281 3584 2069 3584 \n",
       "Q 2775 3584 3186 3129 \n",
       "Q 3597 2675 3597 1894 \n",
       "z\n",
       "M 3022 2063 \n",
       "Q 3016 2534 2758 2815 \n",
       "Q 2500 3097 2075 3097 \n",
       "Q 1594 3097 1305 2825 \n",
       "Q 1016 2553 972 2059 \n",
       "L 3022 2063 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-20\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-3d\" d=\"M 678 2906 \n",
       "L 4684 2906 \n",
       "L 4684 2381 \n",
       "L 678 2381 \n",
       "L 678 2906 \n",
       "z\n",
       "M 678 1631 \n",
       "L 4684 1631 \n",
       "L 4684 1100 \n",
       "L 678 1100 \n",
       "L 678 1631 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-35\" d=\"M 691 4666 \n",
       "L 3169 4666 \n",
       "L 3169 4134 \n",
       "L 1269 4134 \n",
       "L 1269 2991 \n",
       "Q 1406 3038 1543 3061 \n",
       "Q 1681 3084 1819 3084 \n",
       "Q 2600 3084 3056 2656 \n",
       "Q 3513 2228 3513 1497 \n",
       "Q 3513 744 3044 326 \n",
       "Q 2575 -91 1722 -91 \n",
       "Q 1428 -91 1123 -41 \n",
       "Q 819 9 494 109 \n",
       "L 494 744 \n",
       "Q 775 591 1075 516 \n",
       "Q 1375 441 1709 441 \n",
       "Q 2250 441 2565 725 \n",
       "Q 2881 1009 2881 1497 \n",
       "Q 2881 1984 2565 2268 \n",
       "Q 2250 2553 1709 2553 \n",
       "Q 1456 2553 1204 2497 \n",
       "Q 953 2441 691 2322 \n",
       "L 691 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-61\" x=\"27.783203\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-62\" x=\"89.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" x=\"152.539062\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\" x=\"214.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"241.845703\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-3d\" x=\"273.632812\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"357.421875\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-35\" x=\"389.208984\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       "  <g id=\"axes_2\">\n",
       "   <g id=\"patch_7\">\n",
       "    <path d=\"M 168.252941 152.765184 \n",
       "L 298.7 152.765184 \n",
       "L 298.7 22.318125 \n",
       "L 168.252941 22.318125 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g clip-path=\"url(#pfc1a76b8e8)\">\n",
       "    <image xlink:href=\"data:image/png;base64,\n",
       "iVBORw0KGgoAAAANSUhEUgAAALYAAAC2CAYAAAB08HcEAAAGq0lEQVR4nO3de2iVdRzH8d9uzillOpE1QtdsR1dBzksoUYraUpKMEk3I5TISZmIWSv8oEiFG5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RNiQRNiQRNiT9C3WSJsq49so9AAAAAElFTkSuQmCC\" id=\"image67fff2862d\" transform=\"scale(1 -1) translate(0 -131.04)\" x=\"168.252941\" y=\"-21.725184\" width=\"131.04\" height=\"131.04\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_3\"/>\n",
       "   <g id=\"matplotlib.axis_4\"/>\n",
       "   <g id=\"patch_8\">\n",
       "    <path d=\"M 168.252941 152.765184 \n",
       "L 168.252941 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_9\">\n",
       "    <path d=\"M 298.7 152.765184 \n",
       "L 298.7 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_10\">\n",
       "    <path d=\"M 168.252941 152.765184 \n",
       "L 298.7 152.765184 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_11\">\n",
       "    <path d=\"M 168.252941 22.318125 \n",
       "L 298.7 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_2\">\n",
       "    <!-- label = 0 -->\n",
       "    <g transform=\"translate(206.305846 16.318125) scale(0.12 -0.12)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-61\" x=\"27.783203\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-62\" x=\"89.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" x=\"152.539062\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\" x=\"214.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"241.845703\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-3d\" x=\"273.632812\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"357.421875\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-30\" x=\"389.208984\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       "  <g id=\"axes_3\">\n",
       "   <g id=\"patch_12\">\n",
       "    <path d=\"M 325.805882 152.765184 \n",
       "L 456.252941 152.765184 \n",
       "L 456.252941 22.318125 \n",
       "L 325.805882 22.318125 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g clip-path=\"url(#pdf64a3fe0f)\">\n",
       "    <image xlink:href=\"data:image/png;base64,\n",
       "iVBORw0KGgoAAAANSUhEUgAAALYAAAC2CAYAAAB08HcEAAAFJUlEQVR4nO3dXWjVZRzA8eec2eYWxXRT0pSygSzoxaARWVHC6Voi88KLIJWiukkKupIuirr1Yjd2GXWVwUpBiQzniqhVM2T0gpUvFW4rKUEXbmenq7p6ftJ2zvmf+d33c/n8eTy/ydfn4uHsb6lS2lZLEky51QNIzWDYQjJsIRm2kAxbS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Obz7Pr0hhXhnvbv5zdXkTyxhWTYQjJsIRm2kAxbSA29FSl/ciJ8NvL3zY38KC3A6UvxG6ci5yrx26P6jtQzTXN5YgvJsIVk2EIybCEZtpAMW0iFvQlqptbyl04tebO7u+KHx/LLnX0XmzJLs3liC8mwhWTYQjJsIRm2kAq7qnjl0BPZ9a6+v4oaYcmr/ngmfNY/vDO7/vRdI+GeowP5t0TVRk/Ob7Am8MQWkmELybCFZNhCMmwhGbaQCrvuW3t8Lrs+Pd5d1Aiaq4aPSmc7s+tHb+qP/7xard6JmsYTW0iGLSTDFpJhC8mwhVTYrUjn+1/k14saQFe1+sv8rdXe7QfDPa+mJ5s1Tt08sYVk2EIybCEZtpAMW0iGLaRSpbRt8X6TRVogT2whGbaQDFtIhi0kwxaSYQvJsIVk2EIybCEZtpAMW0iGLSTDFpJhC8mwhWTYQjJsIRm2kAxbSIYtJMMWkmELybCFZNhCMmwhGbaQDFtIhi0kwxaSYQvJsIX0D+IxqjxHZ+heAAAAAElFTkSuQmCC\" id=\"image5027106549\" transform=\"scale(1 -1) translate(0 -131.04)\" x=\"325.805882\" y=\"-21.725184\" width=\"131.04\" height=\"131.04\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_5\"/>\n",
       "   <g id=\"matplotlib.axis_6\"/>\n",
       "   <g id=\"patch_13\">\n",
       "    <path d=\"M 325.805882 152.765184 \n",
       "L 325.805882 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_14\">\n",
       "    <path d=\"M 456.252941 152.765184 \n",
       "L 456.252941 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_15\">\n",
       "    <path d=\"M 325.805882 152.765184 \n",
       "L 456.252941 152.765184 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_16\">\n",
       "    <path d=\"M 325.805882 22.318125 \n",
       "L 456.252941 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_3\">\n",
       "    <!-- label = 4 -->\n",
       "    <g transform=\"translate(363.858787 16.318125) scale(0.12 -0.12)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-34\" d=\"M 2419 4116 \n",
       "L 825 1625 \n",
       "L 2419 1625 \n",
       "L 2419 4116 \n",
       "z\n",
       "M 2253 4666 \n",
       "L 3047 4666 \n",
       "L 3047 1625 \n",
       "L 3713 1625 \n",
       "L 3713 1100 \n",
       "L 3047 1100 \n",
       "L 3047 0 \n",
       "L 2419 0 \n",
       "L 2419 1100 \n",
       "L 313 1100 \n",
       "L 313 1709 \n",
       "L 2253 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-61\" x=\"27.783203\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-62\" x=\"89.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" x=\"152.539062\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\" x=\"214.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"241.845703\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-3d\" x=\"273.632812\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"357.421875\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-34\" x=\"389.208984\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       "  <g id=\"axes_4\">\n",
       "   <g id=\"patch_17\">\n",
       "    <path d=\"M 10.7 309.301654 \n",
       "L 141.147059 309.301654 \n",
       "L 141.147059 178.854596 \n",
       "L 10.7 178.854596 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g clip-path=\"url(#pdc8e7eee89)\">\n",
       "    <image xlink:href=\"data:image/png;base64,\n",
       "iVBORw0KGgoAAAANSUhEUgAAALYAAAC2CAYAAAB08HcEAAAEwElEQVR4nO3dzYvVVRzH8d84Tmi6KUSmmtEiUEGRAqOUQiOlaFEho1Q7a9WjPUKBi1YtInqiwCQIQpMywdoFQUQRWVFgPpBY2KhUiBrhhMw4M/0D51y4cp1xPvN6Lb+HM7+7eHMWh/u707W2a2C8gTAzJvsDwMUgbCIJm0jCJpKwiSRsIgmbSMImkrCJJGwiCZtIwiaSsIkkbCIJm0jCJpKwiSRsIgmbSDMn+wN02szrFhbnvTtPVfds7f+qOP/47Pzqng8W97f3wZhQTmwiCZtIwiaSsIkkbCLF3Yr8e0Nvcb6rb1eLXd0X58MwaZzYRBI2kYRNJGETSdhEEjaRhE0kYRNJ2EQSNpGETSRhEynuS1CzTg8X59+cm1Pdc/vsc8X5nZcPVvds2ba+OF/y9MHqnrGhoeoaneXEJpKwiSRsIgmbSMImkrCJ1LW2a2B8sj/ERDj2ybLq2sFV24vzkfHRtp9z77oHqmujBw+3/fe4ME5sIgmbSMImkrCJJGwixX0JqqZ/YH91beRE+fbjQm5F/lwzr7o2363IhHFiE0nYRBI2kYRNJGETSdhEmjbXfa38PDxWnC/raf9vrdz0U3Xt6M4rivPRM2fafxAtObGJJGwiCZtIwiaSsIk0bV4Na2Vs9Y3F+cPb9lT33DPn77afs27//cX53Lt+b/tv0ZoTm0jCJpKwiSRsIgmbSMImkuu+Fn7bUb4GbJqm2bf63Y49Z/19D1XXxn+sv6tJnRObSMImkrCJJGwiCZtIXg1rYdHL/1XXetZ0d+w5gy/U1/oHOvaYacWJTSRhE0nYRBI2kYRNJGETyXVfC6MHfq2urdryeHG+46VXq3v6uss/LbWy72h1z1/XLijOzx8drO7BiU0oYRNJ2EQSNpGETSSvhnXY8RdXVdd+eOyN4rynq/6Fqg1H7i7OhwfKv+ndNE0zevJkdW26cGITSdhEEjaRhE0kYRNJ2ERy3ddh3UsXV9du+rD8q05b5u2r7hkZHy3Ol3/0ZHXP9c9+V12bLpzYRBI2kYRNJGETSdhEcisygWb2XVOc79n7WXVP7Vbk0Ej9OZufe6I4n7N7b31TGCc2kYRNJGETSdhEEjaRhE0kvwQ1gc4fP1GcL/16U3XPgdveL86XX1Z/zoJnDhfnp3bX96RxYhNJ2EQSNpGETSRhE8mtyCXgqu2zqmtfriiv3TprqLrnvYWfF+crNz9V3dP75rfVtanIiU0kYRNJ2EQSNpGETSRhE8k7j5e4sxtuLs7feeWt6p5FPV3F+dZ/llT3fLFxRXE+/kf5i1tN0zRjQ/Urx8nmxCaSsIkkbCIJm0jCJpJbkSnqyGu3VNd+2Vi/Mamp/Uu+Ox59pLpn9qfft/2cieLEJpKwiSRsIgmbSMImkrCJ5J3HKWrusfqZdHpsuDi/ckaLn48K48QmkrCJJGwiCZtIwiaSW5Epqvf1+i83rbn6+eL80INvV/fUvgTVlN8yu+Q5sYkkbCIJm0jCJpKwiSRsInnnkUhObCIJm0jCJpKwiSRsIgmbSMImkrCJJGwiCZtIwiaSsIkkbCIJm0jCJpKwiSRsIgmbSMImkrCJJGwiCZtIwiaSsIkkbCIJm0jCJpKwiSRsIgmbSMIm0v8oMaZNofO8yAAAAABJRU5ErkJggg==\" id=\"image08df12709d\" transform=\"scale(1 -1) translate(0 -131.04)\" x=\"10.7\" y=\"-178.261654\" width=\"131.04\" height=\"131.04\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_7\"/>\n",
       "   <g id=\"matplotlib.axis_8\"/>\n",
       "   <g id=\"patch_18\">\n",
       "    <path d=\"M 10.7 309.301654 \n",
       "L 10.7 178.854596 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_19\">\n",
       "    <path d=\"M 141.147059 309.301654 \n",
       "L 141.147059 178.854596 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_20\">\n",
       "    <path d=\"M 10.7 309.301654 \n",
       "L 141.147059 309.301654 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_21\">\n",
       "    <path d=\"M 10.7 178.854596 \n",
       "L 141.147059 178.854596 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_4\">\n",
       "    <!-- label = 1 -->\n",
       "    <g transform=\"translate(48.752904 172.854596) scale(0.12 -0.12)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-31\" d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-61\" x=\"27.783203\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-62\" x=\"89.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" x=\"152.539062\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\" x=\"214.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"241.845703\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-3d\" x=\"273.632812\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"357.421875\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-31\" x=\"389.208984\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       "  <g id=\"axes_5\">\n",
       "   <g id=\"patch_22\">\n",
       "    <path d=\"M 168.252941 309.301654 \n",
       "L 298.7 309.301654 \n",
       "L 298.7 178.854596 \n",
       "L 168.252941 178.854596 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g clip-path=\"url(#p628830b5c4)\">\n",
       "    <image xlink:href=\"data:image/png;base64,\n",
       "iVBORw0KGgoAAAANSUhEUgAAALYAAAC2CAYAAAB08HcEAAAFwklEQVR4nO3d32vVdRzH8c/Z2c7mGWvNRKHyR7HSwGzFwFqIJEe9KSOdOIvKIdQiFQcSSl01u8oRJsWESBGCoCQSurBf4JVzmZlQW60fmz9YosbWwv3e6R94v7/wXcft7HWej8v3l8/OB/f0c/HhnLNEJlGfDYCYopneAHArEDYkETYkETYkETYkETYkFc/0BhBCct4d7rOu1sXmvDNz2F2zYdN2+0H7hVj7ms04sSGJsCGJsCGJsCGJsCGJW5Fp5N1+pI77v4bOavv2Y/WPW901c7t6zflExN7UcGJDEmFDEmFDEmFDEmFDEmFDEtd90+jK80vNeUf1QXdNY886c175ZtpdM9E/EG9jgjixIYmwIYmwIYmwIYmwIYlbkWnU/PKnsdf0tVSb81T7d/93O9I4sSGJsCGJsCGJsCGJsCGJsCGJ674cyz5e4z7bdtt5cz6W9c+X9E995nw8zqYKECc2JBE2JBE2JBE2JBE2JHErkmNXVvsf2RrL2t/FNBkmb9V2ChYnNiQRNiQRNiQRNiQRNiQRNiRx3ZdjlX9wdZcPOLEhibAhibAhibAhibAhiVuRHKv4uN1/2Dp9+yh0nNiQRNiQRNiQRNiQRNiQRNiQxHVfjg02PBrx9Ptp20eh48SGJMKGJMKGJMKGJMKGJG5Fcqx4yP9oWEkiac7Hsv7P+3PbInO+sOVyrH0VGk5sSCJsSCJsSCJsSCJsSCJsSJqV132j62vdZ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xIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxIImxI+g8q8N7IPYABNwAAAABJRU5ErkJggg==\" id=\"image00188672ed\" transform=\"scale(1 -1) translate(0 -131.04)\" x=\"168.252941\" y=\"-178.261654\" width=\"131.04\" height=\"131.04\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_9\"/>\n",
       "   <g id=\"matplotlib.axis_10\"/>\n",
       "   <g id=\"patch_23\">\n",
       "    <path d=\"M 168.252941 309.301654 \n",
       "L 168.252941 178.854596 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_24\">\n",
       "    <path d=\"M 298.7 309.301654 \n",
       "L 298.7 178.854596 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_25\">\n",
       "    <path d=\"M 168.252941 309.301654 \n",
       "L 298.7 309.301654 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_26\">\n",
       "    <path d=\"M 168.252941 178.854596 \n",
       "L 298.7 178.854596 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_5\">\n",
       "    <!-- label = 9 -->\n",
       "    <g transform=\"translate(206.305846 172.854596) scale(0.12 -0.12)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-39\" d=\"M 703 97 \n",
       "L 703 672 \n",
       "Q 941 559 1184 500 \n",
       "Q 1428 441 1663 441 \n",
       "Q 2288 441 2617 861 \n",
       "Q 2947 1281 2994 2138 \n",
       "Q 2813 1869 2534 1725 \n",
       "Q 2256 1581 1919 1581 \n",
       "Q 1219 1581 811 2004 \n",
       "Q 403 2428 403 3163 \n",
       "Q 403 3881 828 4315 \n",
       "Q 1253 4750 1959 4750 \n",
       "Q 2769 4750 3195 4129 \n",
       "Q 3622 3509 3622 2328 \n",
       "Q 3622 1225 3098 567 \n",
       "Q 2575 -91 1691 -91 \n",
       "Q 1453 -91 1209 -44 \n",
       "Q 966 3 703 97 \n",
       "z\n",
       "M 1959 2075 \n",
       "Q 2384 2075 2632 2365 \n",
       "Q 2881 2656 2881 3163 \n",
       "Q 2881 3666 2632 3958 \n",
       "Q 2384 4250 1959 4250 \n",
       "Q 1534 4250 1286 3958 \n",
       "Q 1038 3666 1038 3163 \n",
       "Q 1038 2656 1286 2365 \n",
       "Q 1534 2075 1959 2075 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-61\" x=\"27.783203\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-62\" x=\"89.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" x=\"152.539062\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\" x=\"214.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"241.845703\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-3d\" x=\"273.632812\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"357.421875\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-39\" x=\"389.208984\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       "  <g id=\"axes_6\">\n",
       "   <g id=\"patch_27\">\n",
       "    <path d=\"M 325.805882 309.301654 \n",
       "L 456.252941 309.301654 \n",
       "L 456.252941 178.854596 \n",
       "L 325.805882 178.854596 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g clip-path=\"url(#p3595a23212)\">\n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AhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAhibAh6V+VmiDtbcouGAAAAABJRU5ErkJggg==\" id=\"imageb50e2c41e1\" transform=\"scale(1 -1) translate(0 -131.04)\" x=\"325.805882\" y=\"-178.261654\" width=\"131.04\" height=\"131.04\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_11\"/>\n",
       "   <g id=\"matplotlib.axis_12\"/>\n",
       "   <g id=\"patch_28\">\n",
       "    <path d=\"M 325.805882 309.301654 \n",
       "L 325.805882 178.854596 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_29\">\n",
       "    <path d=\"M 456.252941 309.301654 \n",
       "L 456.252941 178.854596 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_30\">\n",
       "    <path d=\"M 325.805882 309.301654 \n",
       "L 456.252941 309.301654 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_31\">\n",
       "    <path d=\"M 325.805882 178.854596 \n",
       "L 456.252941 178.854596 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_6\">\n",
       "    <!-- label = 2 -->\n",
       "    <g transform=\"translate(363.858787 172.854596) scale(0.12 -0.12)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-32\" d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-61\" x=\"27.783203\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-62\" x=\"89.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" x=\"152.539062\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\" x=\"214.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"241.845703\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-3d\" x=\"273.632812\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"357.421875\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-32\" x=\"389.208984\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       "  <g id=\"axes_7\">\n",
       "   <g id=\"patch_32\">\n",
       "    <path d=\"M 10.7 465.838125 \n",
       "L 141.147059 465.838125 \n",
       "L 141.147059 335.391066 \n",
       "L 10.7 335.391066 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g clip-path=\"url(#p78a7eb4643)\">\n",
       "    <image xlink:href=\"data:image/png;base64,\n",
       "iVBORw0KGgoAAAANSUhEUgAAALYAAAC2CAYAAAB08HcEAAADqElEQVR4nO3cMYtcVRiA4d2swUbZaBEEJRLQKRTBwkIEG1k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L45czw/+UiU2SsEkSNknCJknYJAmbJGGTJGyShE2SsEkSNknCJknYJAmbJGGTJGyShE2SsEkSNknCJknYJAmbJGGTJGyShE3SP2WWVeoPDj7TAAAAAElFTkSuQmCC\" id=\"image98fe05353d\" transform=\"scale(1 -1) translate(0 -131.04)\" x=\"10.7\" y=\"-334.798125\" width=\"131.04\" height=\"131.04\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_13\"/>\n",
       "   <g id=\"matplotlib.axis_14\"/>\n",
       "   <g id=\"patch_33\">\n",
       "    <path d=\"M 10.7 465.838125 \n",
       "L 10.7 335.391066 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_34\">\n",
       "    <path d=\"M 141.147059 465.838125 \n",
       "L 141.147059 335.391066 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_35\">\n",
       "    <path d=\"M 10.7 465.838125 \n",
       "L 141.147059 465.838125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_36\">\n",
       "    <path d=\"M 10.7 335.391066 \n",
       "L 141.147059 335.391066 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_7\">\n",
       "    <!-- label = 1 -->\n",
       "    <g transform=\"translate(48.752904 329.391066) scale(0.12 -0.12)\">\n",
       "     <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-61\" x=\"27.783203\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-62\" x=\"89.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" x=\"152.539062\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\" x=\"214.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"241.845703\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-3d\" x=\"273.632812\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"357.421875\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-31\" x=\"389.208984\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       "  <g id=\"axes_8\">\n",
       "   <g id=\"patch_37\">\n",
       "    <path d=\"M 168.252941 465.838125 \n",
       "L 298.7 465.838125 \n",
       "L 298.7 335.391066 \n",
       "L 168.252941 335.391066 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g clip-path=\"url(#p1976429d1d)\">\n",
       "    <image xlink:href=\"data:image/png;base64,\n",
       "iVBORw0KGgoAAAANSUhEUgAAALYAAAC2CAYAAAB08HcEAAAF4UlEQVR4nO3df2jUdRzH8bvbTzdq2qrlwpVjmGU/xoporthaAyOosBYrlLTJMCUlmEV/iBD9J0U/ycBwBIZIsIiR0IioP9xaUVZuLOdK1NZa9oPy17bb3fqnoD/e7+HdvvfD1z0ff74/fO6+yJMP+OHuFm4Jt86GADGRTD8AkAqEDUmEDUmEDUmEDUmEDUmEDUmEDUmEDUmEDUmEDUmEDUmEDUmEDUmEDUmEDUmEDUmEDUmEDUn5mX6AuURKSsz5ya217p53Nr5izm8sDLt7mg+3mfO/Pr3K3XPN/jFzPnPsuLsH6cOJDUmEDUmEDUmEDUmEDUnhTP8SVKypzl37aXPUnH/bsCdVj3PB9v69xJyPRxe6e/Z83WDOa3bH3D3hg98k8lj4Fyc2JBE2JBE2JBE2JBE2JBE2JGX8uq/xu/PuWmf5YBqfJPUizjlycLLA3dMx8Lg5r+k46u6Jnz2b2IMJ4sSGJMKGJMKGJMKGJMKGpKz+algyrv94o71wxr95CNKjK/vdteevPGTO64un3D2DjbvN+breVe6e0a6bzXn52/6z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+6eiHOOBP3n8MCJDVGEDUmEDUmEDUmEDUmEDUk5c90X3n6Zu7Z8vf1hnpeb97l7CsIz5jzIDyBlg9q+dndt6cCP5jyWqodJACc2JBE2JBE2JBE2JBE2JPHn8OYQvnWFuxYvtC+UxppK3T1DW94059HZzN8j3DPYas5LHxx398QnJ1P1OPPGiQ1JhA1JhA1JhA1JhA1JhA1JXPdBEic2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JBE2JP0Dt7Dl2LaNl84AAAAASUVORK5CYII=\" id=\"image6dc7d0021c\" transform=\"scale(1 -1) translate(0 -131.04)\" x=\"168.252941\" y=\"-334.798125\" width=\"131.04\" height=\"131.04\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_15\"/>\n",
       "   <g id=\"matplotlib.axis_16\"/>\n",
       "   <g id=\"patch_38\">\n",
       "    <path d=\"M 168.252941 465.838125 \n",
       "L 168.252941 335.391066 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_39\">\n",
       "    <path d=\"M 298.7 465.838125 \n",
       "L 298.7 335.391066 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_40\">\n",
       "    <path d=\"M 168.252941 465.838125 \n",
       "L 298.7 465.838125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_41\">\n",
       "    <path d=\"M 168.252941 335.391066 \n",
       "L 298.7 335.391066 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_8\">\n",
       "    <!-- label = 3 -->\n",
       "    <g transform=\"translate(206.305846 329.391066) scale(0.12 -0.12)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-33\" d=\"M 2597 2516 \n",
       "Q 3050 2419 3304 2112 \n",
       "Q 3559 1806 3559 1356 \n",
       "Q 3559 666 3084 287 \n",
       "Q 2609 -91 1734 -91 \n",
       "Q 1441 -91 1130 -33 \n",
       "Q 819 25 488 141 \n",
       "L 488 750 \n",
       "Q 750 597 1062 519 \n",
       "Q 1375 441 1716 441 \n",
       "Q 2309 441 2620 675 \n",
       "Q 2931 909 2931 1356 \n",
       "Q 2931 1769 2642 2001 \n",
       "Q 2353 2234 1838 2234 \n",
       "L 1294 2234 \n",
       "L 1294 2753 \n",
       "L 1863 2753 \n",
       "Q 2328 2753 2575 2939 \n",
       "Q 2822 3125 2822 3475 \n",
       "Q 2822 3834 2567 4026 \n",
       "Q 2313 4219 1838 4219 \n",
       "Q 1578 4219 1281 4162 \n",
       "Q 984 4106 628 3988 \n",
       "L 628 4550 \n",
       "Q 988 4650 1302 4700 \n",
       "Q 1616 4750 1894 4750 \n",
       "Q 2613 4750 3031 4423 \n",
       "Q 3450 4097 3450 3541 \n",
       "Q 3450 3153 3228 2886 \n",
       "Q 3006 2619 2597 2516 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-61\" x=\"27.783203\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-62\" x=\"89.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" x=\"152.539062\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\" x=\"214.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"241.845703\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-3d\" x=\"273.632812\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"357.421875\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-33\" x=\"389.208984\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       "  <g id=\"axes_9\">\n",
       "   <g id=\"patch_42\">\n",
       "    <path d=\"M 325.805882 465.838125 \n",
       "L 456.252941 465.838125 \n",
       "L 456.252941 335.391066 \n",
       "L 325.805882 335.391066 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g clip-path=\"url(#p3da9b1a653)\">\n",
       "    <image xlink:href=\"data:image/png;base64,\n",
       "iVBORw0KGgoAAAANSUhEUgAAALYAAAC2CAYAAAB08HcEAAADoElEQVR4nO3dsWvcZRjA8bumCa0KDoUKQlGoFgQpuFVwEQr+AQZcHFQQCq5u/gkOujjo4iw4ujhJcVNUXDIEpaijNQ5trbRJzlHQ36+Q6+Xu+ObzGd/jpS/hyzM8XNLp1en2bAIxp1b9ADgOwiZJ2CQJmyRhkyRskoRNkrBJEjZJwiZJ2CQJmyRhkyRskoRNkrBJEjZJwiZJ2CSdXvUDTpK9Ly4Nnm8/9cPoneuvvTB4frCzu5A3VZnYJAmbJGGTJGyShE2SrcgSvf/c54Pnz2/dGr3z1aNXjus5aSY2ScImSdgkCZskYZMkbJKs+5bozetvDZ7/9Mono3duXn5s8Pzctwt5UpaJTZKwSRI2ScImSdgk2YqsgZ/3745+du7Tb5b4kg4TmyRhkyRskoRNkrBJEjZJ1n1rYGMyG/3s1Nkzg+eHd+4c13MSTGyShE2SsEkSNknCJslWZInevfLl4PnTpx8ZvbP78fDf1H7m9fG/qY2JTZSwSRI2ScImSdgkCZsk674F+/ONF0c/u/b4R4PnfxyO/87jsx/cGzwf/9oUk4mJTZSwSRI2ScImSdgk2Yos2OEcP9GD2QN+Nezu/eE7R/9nThQTmyRhkyRskoRNkrBJEjZJ1n0LdvvC9Mh3bs3G7xzs7D7Mc04sE5skYZMkbJKETZKwSbIVWbALL/226icwMbGJEjZJwiZJ2CQJmyRhk2TdtwZe/f7t0c+enOws8SUdJjZJwiZJ2CQJmyRhk2QrsgZu743/d3jMx8QmSdgkCZskYZMkbJKETZKwSRI2ScImSdgkCZskYZPkS1Bz2nji/OD5hxc/e8CtM8fzGP7HxCZJ2CQJmyRhkyRskoRNknXfnKabm4PnlzaPvtI7e2PrYZ/Df5jYJAmbJGGTJGyShE2SrcgaOP/d/VU/IcfEJknYJAmbJGGTJGyShE2Sdd8SbUyH58jmX/tLfkmfiU2SsEkSNknCJknYJNmKLNHB7HDVTzgxTGyShE2SsEkSNknCJknYJFn3LdHXfw//uLd+3Ru94+tR8zGxSRI2ScImSdgkCZskW5E5Hfx+c/D85Xeujd65/N6Pg+f7N35ZyJv4l4lNkrBJEjZJwiZJ2CQJm6Tp1en2bNWPgEUzsUkSNknCJknYJAmbJGGTJGyShE2SsEkSNknCJknYJAmbJGGTJGyShE2SsEkSNknCJknYJAmbJGGTJGyShE2SsEkSNknCJknYJAmbJGGTJGyS/gFus1H2ieajhgAAAABJRU5ErkJggg==\" id=\"imageb275b3c368\" transform=\"scale(1 -1) translate(0 -131.04)\" x=\"325.805882\" y=\"-334.798125\" width=\"131.04\" height=\"131.04\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_17\"/>\n",
       "   <g id=\"matplotlib.axis_18\"/>\n",
       "   <g id=\"patch_43\">\n",
       "    <path d=\"M 325.805882 465.838125 \n",
       "L 325.805882 335.391066 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_44\">\n",
       "    <path d=\"M 456.252941 465.838125 \n",
       "L 456.252941 335.391066 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_45\">\n",
       "    <path d=\"M 325.805882 465.838125 \n",
       "L 456.252941 465.838125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_46\">\n",
       "    <path d=\"M 325.805882 335.391066 \n",
       "L 456.252941 335.391066 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_9\">\n",
       "    <!-- label = 1 -->\n",
       "    <g transform=\"translate(363.858787 329.391066) scale(0.12 -0.12)\">\n",
       "     <use xlink:href=\"#DejaVuSans-6c\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-61\" x=\"27.783203\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-62\" x=\"89.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" x=\"152.539062\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\" x=\"214.0625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"241.845703\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-3d\" x=\"273.632812\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"357.421875\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-31\" x=\"389.208984\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p050aa697bb\">\n",
       "   <rect x=\"10.7\" y=\"22.318125\" width=\"130.447059\" height=\"130.447059\"/>\n",
       "  </clipPath>\n",
       "  <clipPath id=\"pfc1a76b8e8\">\n",
       "   <rect x=\"168.252941\" y=\"22.318125\" width=\"130.447059\" height=\"130.447059\"/>\n",
       "  </clipPath>\n",
       "  <clipPath id=\"pdf64a3fe0f\">\n",
       "   <rect x=\"325.805882\" y=\"22.318125\" width=\"130.447059\" height=\"130.447059\"/>\n",
       "  </clipPath>\n",
       "  <clipPath id=\"pdc8e7eee89\">\n",
       "   <rect x=\"10.7\" y=\"178.854596\" width=\"130.447059\" height=\"130.447059\"/>\n",
       "  </clipPath>\n",
       "  <clipPath id=\"p628830b5c4\">\n",
       "   <rect x=\"168.252941\" y=\"178.854596\" width=\"130.447059\" height=\"130.447059\"/>\n",
       "  </clipPath>\n",
       "  <clipPath id=\"p3595a23212\">\n",
       "   <rect x=\"325.805882\" y=\"178.854596\" width=\"130.447059\" height=\"130.447059\"/>\n",
       "  </clipPath>\n",
       "  <clipPath id=\"p78a7eb4643\">\n",
       "   <rect x=\"10.7\" y=\"335.391066\" width=\"130.447059\" height=\"130.447059\"/>\n",
       "  </clipPath>\n",
       "  <clipPath id=\"p1976429d1d\">\n",
       "   <rect x=\"168.252941\" y=\"335.391066\" width=\"130.447059\" height=\"130.447059\"/>\n",
       "  </clipPath>\n",
       "  <clipPath id=\"p3da9b1a653\">\n",
       "   <rect x=\"325.805882\" y=\"335.391066\" width=\"130.447059\" height=\"130.447059\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 800x800 with 9 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "%config InlineBackend.figure_format = 'svg'\n",
    "\n",
    "#查看部分样本\n",
    "from matplotlib import pyplot as plt \n",
    "\n",
    "plt.figure(figsize=(8,8)) \n",
    "for i in range(9):\n",
    "    img,label = ds_train[i]\n",
    "    img = torch.squeeze(img)\n",
    "    ax=plt.subplot(3,3,i+1)\n",
    "    ax.imshow(img.numpy())\n",
    "    ax.set_title(\"label = %d\"%label)\n",
    "    ax.set_xticks([])\n",
    "    ax.set_yticks([]) \n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8a3238e3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "99c0512e",
   "metadata": {},
   "source": [
    "### 一，脚本风格"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4d305aa4",
   "metadata": {},
   "source": [
    "脚本风格的训练循环非常常见。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "9dad7971",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Sequential(\n",
      "  (conv1): Conv2d(1, 32, kernel_size=(3, 3), stride=(1, 1))\n",
      "  (pool1): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
      "  (conv2): Conv2d(32, 64, kernel_size=(5, 5), stride=(1, 1))\n",
      "  (pool2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
      "  (dropout): Dropout2d(p=0.1, inplace=False)\n",
      "  (adaptive_pool): AdaptiveMaxPool2d(output_size=(1, 1))\n",
      "  (flatten): Flatten(start_dim=1, end_dim=-1)\n",
      "  (linear1): Linear(in_features=64, out_features=32, bias=True)\n",
      "  (relu): ReLU()\n",
      "  (linear2): Linear(in_features=32, out_features=10, bias=True)\n",
      ")\n"
     ]
    }
   ],
   "source": [
    "net = nn.Sequential()\n",
    "net.add_module(\"conv1\",nn.Conv2d(in_channels=1,out_channels=32,kernel_size = 3))\n",
    "net.add_module(\"pool1\",nn.MaxPool2d(kernel_size = 2,stride = 2))\n",
    "net.add_module(\"conv2\",nn.Conv2d(in_channels=32,out_channels=64,kernel_size = 5))\n",
    "net.add_module(\"pool2\",nn.MaxPool2d(kernel_size = 2,stride = 2))\n",
    "net.add_module(\"dropout\",nn.Dropout2d(p = 0.1))\n",
    "net.add_module(\"adaptive_pool\",nn.AdaptiveMaxPool2d((1,1)))\n",
    "net.add_module(\"flatten\",nn.Flatten())\n",
    "net.add_module(\"linear1\",nn.Linear(64,32))\n",
    "net.add_module(\"relu\",nn.ReLU())\n",
    "net.add_module(\"linear2\",nn.Linear(32,10))\n",
    "\n",
    "print(net)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b4f99414",
   "metadata": {},
   "source": [
    "```\n",
    "Sequential(\n",
    "  (conv1): Conv2d(1, 32, kernel_size=(3, 3), stride=(1, 1))\n",
    "  (pool1): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
    "  (conv2): Conv2d(32, 64, kernel_size=(5, 5), stride=(1, 1))\n",
    "  (pool2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
    "  (dropout): Dropout2d(p=0.1, inplace=False)\n",
    "  (adaptive_pool): AdaptiveMaxPool2d(output_size=(1, 1))\n",
    "  (flatten): Flatten()\n",
    "  (linear1): Linear(in_features=64, out_features=32, bias=True)\n",
    "  (relu): ReLU()\n",
    "  (linear2): Linear(in_features=32, out_features=10, bias=True)\n",
    ")\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "417a87bd-8e15-4872-a5c2-f6d41f2247ce",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os,sys,time\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import datetime \n",
    "from tqdm import tqdm \n",
    "\n",
    "import torch\n",
    "from torch import nn \n",
    "from copy import deepcopy\n",
    "from torchmetrics import Accuracy\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "bc9fb1ae-2e9e-45ed-a12b-007068e2fd33",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 16:52:38\n",
      "Epoch 1 / 20\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:23<00:00, 20.37it/s, train_acc=0.906, train_loss=0.289]\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 33.64it/s, val_acc=0.976, val_loss=0.0822]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 16:53:03\n",
      "Epoch 2 / 20\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "<<<<<< reach best val_acc : 0.9758999943733215 >>>>>>\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:22<00:00, 20.78it/s, train_acc=0.967, train_loss=0.11]\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 32.63it/s, val_acc=0.979, val_loss=0.0773]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 16:53:28\n",
      "Epoch 3 / 20\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "<<<<<< reach best val_acc : 0.979200005531311 >>>>>>\n",
      "100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:22<00:00, 20.75it/s, train_acc=0.973, train_loss=0.0915]\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 33.50it/s, val_acc=0.977, val_loss=0.0741]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 16:53:53\n",
      "Epoch 4 / 20\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:22<00:00, 20.87it/s, train_acc=0.972, train_loss=0.0959]\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 33.15it/s, val_acc=0.977, val_loss=0.0782]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 16:54:18\n",
      "Epoch 5 / 20\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:22<00:00, 20.46it/s, train_acc=0.969, train_loss=0.103]\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 32.36it/s, val_acc=0.978, val_loss=0.0748]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 16:54:44\n",
      "Epoch 6 / 20\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:22<00:00, 20.46it/s, train_acc=0.971, train_loss=0.0955]\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 32.96it/s, val_acc=0.974, val_loss=0.0871]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 16:55:09\n",
      "Epoch 7 / 20\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:22<00:00, 20.65it/s, train_acc=0.969, train_loss=0.105]\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 34.38it/s, val_acc=0.976, val_loss=0.0843]\n",
      "<<<<<< val_acc without improvement in 5 epoch, early stopping >>>>>>\n"
     ]
    }
   ],
   "source": [
    "def printlog(info):\n",
    "    nowtime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')\n",
    "    print(\"\\n\"+\"==========\"*8 + \"%s\"%nowtime)\n",
    "    print(str(info)+\"\\n\")\n",
    "    \n",
    "loss_fn = nn.CrossEntropyLoss()\n",
    "optimizer= torch.optim.Adam(net.parameters(),lr = 0.01)   \n",
    "metrics_dict = {\"acc\":Accuracy(task='multiclass',num_classes=10)}\n",
    "\n",
    "epochs = 20 \n",
    "ckpt_path='checkpoint.pt'\n",
    "\n",
    "#early_stopping相关设置\n",
    "monitor=\"val_acc\"\n",
    "patience=5\n",
    "mode=\"max\"\n",
    "\n",
    "history = {}\n",
    "\n",
    "for epoch in range(1, epochs+1):\n",
    "    printlog(\"Epoch {0} / {1}\".format(epoch, epochs))\n",
    "\n",
    "    # 1，train -------------------------------------------------  \n",
    "    net.train()\n",
    "    \n",
    "    total_loss,step = 0,0\n",
    "    \n",
    "    loop = tqdm(enumerate(dl_train), total =len(dl_train))\n",
    "    train_metrics_dict = deepcopy(metrics_dict) \n",
    "    \n",
    "    for i, batch in loop: \n",
    "        \n",
    "        features,labels = batch\n",
    "        #forward\n",
    "        preds = net(features)\n",
    "        loss = loss_fn(preds,labels)\n",
    "        \n",
    "        #backward\n",
    "        loss.backward()\n",
    "        optimizer.step()\n",
    "        optimizer.zero_grad()\n",
    "            \n",
    "        #metrics\n",
    "        step_metrics = {\"train_\"+name:metric_fn(preds, labels).item() \n",
    "                        for name,metric_fn in train_metrics_dict.items()}\n",
    "        \n",
    "        step_log = dict({\"train_loss\":loss.item()},**step_metrics)\n",
    "\n",
    "        total_loss += loss.item()\n",
    "        \n",
    "        step+=1\n",
    "        if i!=len(dl_train)-1:\n",
    "            loop.set_postfix(**step_log)\n",
    "        else:\n",
    "            epoch_loss = total_loss/step\n",
    "            epoch_metrics = {\"train_\"+name:metric_fn.compute().item() \n",
    "                             for name,metric_fn in train_metrics_dict.items()}\n",
    "            epoch_log = dict({\"train_loss\":epoch_loss},**epoch_metrics)\n",
    "            loop.set_postfix(**epoch_log)\n",
    "\n",
    "            for name,metric_fn in train_metrics_dict.items():\n",
    "                metric_fn.reset()\n",
    "                \n",
    "    for name, metric in epoch_log.items():\n",
    "        history[name] = history.get(name, []) + [metric]\n",
    "        \n",
    "\n",
    "    # 2，validate -------------------------------------------------\n",
    "    net.eval()\n",
    "    \n",
    "    total_loss,step = 0,0\n",
    "    loop = tqdm(enumerate(dl_val), total =len(dl_val))\n",
    "    \n",
    "    val_metrics_dict = deepcopy(metrics_dict) \n",
    "    \n",
    "    with torch.no_grad():\n",
    "        for i, batch in loop: \n",
    "\n",
    "            features,labels = batch\n",
    "            \n",
    "            #forward\n",
    "            preds = net(features)\n",
    "            loss = loss_fn(preds,labels)\n",
    "\n",
    "            #metrics\n",
    "            step_metrics = {\"val_\"+name:metric_fn(preds, labels).item() \n",
    "                            for name,metric_fn in val_metrics_dict.items()}\n",
    "\n",
    "            step_log = dict({\"val_loss\":loss.item()},**step_metrics)\n",
    "\n",
    "            total_loss += loss.item()\n",
    "            step+=1\n",
    "            if i!=len(dl_val)-1:\n",
    "                loop.set_postfix(**step_log)\n",
    "            else:\n",
    "                epoch_loss = (total_loss/step)\n",
    "                epoch_metrics = {\"val_\"+name:metric_fn.compute().item() \n",
    "                                 for name,metric_fn in val_metrics_dict.items()}\n",
    "                epoch_log = dict({\"val_loss\":epoch_loss},**epoch_metrics)\n",
    "                loop.set_postfix(**epoch_log)\n",
    "\n",
    "                for name,metric_fn in val_metrics_dict.items():\n",
    "                    metric_fn.reset()\n",
    "                    \n",
    "    epoch_log[\"epoch\"] = epoch           \n",
    "    for name, metric in epoch_log.items():\n",
    "        history[name] = history.get(name, []) + [metric]\n",
    "\n",
    "    # 3，early-stopping -------------------------------------------------\n",
    "    arr_scores = history[monitor]\n",
    "    best_score_idx = np.argmax(arr_scores) if mode==\"max\" else np.argmin(arr_scores)\n",
    "    if best_score_idx==len(arr_scores)-1:\n",
    "        torch.save(net.state_dict(),ckpt_path)\n",
    "        print(\"<<<<<< reach best {0} : {1} >>>>>>\".format(monitor,\n",
    "             arr_scores[best_score_idx]),file=sys.stderr)\n",
    "    if len(arr_scores)-best_score_idx>patience:\n",
    "        print(\"<<<<<< {} without improvement in {} epoch, early stopping >>>>>>\".format(\n",
    "            monitor,patience),file=sys.stderr)\n",
    "        break \n",
    "    net.load_state_dict(torch.load(ckpt_path))\n",
    "    \n",
    "dfhistory = pd.DataFrame(history)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2605b75e-15f9-4a4a-a31f-00a6a5d0b228",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "c726168a",
   "metadata": {},
   "source": [
    "### 二，函数风格"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "48817db4",
   "metadata": {},
   "source": [
    "该风格在脚本形式上做了进一步的函数封装。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "0a1a41d9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Net(\n",
      "  (layers): ModuleList(\n",
      "    (0): Conv2d(1, 32, kernel_size=(3, 3), stride=(1, 1))\n",
      "    (1): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
      "    (2): Conv2d(32, 64, kernel_size=(5, 5), stride=(1, 1))\n",
      "    (3): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
      "    (4): Dropout2d(p=0.1, inplace=False)\n",
      "    (5): AdaptiveMaxPool2d(output_size=(1, 1))\n",
      "    (6): Flatten(start_dim=1, end_dim=-1)\n",
      "    (7): Linear(in_features=64, out_features=32, bias=True)\n",
      "    (8): ReLU()\n",
      "    (9): Linear(in_features=32, out_features=10, bias=True)\n",
      "  )\n",
      ")\n"
     ]
    }
   ],
   "source": [
    "class Net(nn.Module):\n",
    "    def __init__(self):\n",
    "        super(Net, self).__init__()\n",
    "        self.layers = nn.ModuleList([\n",
    "            nn.Conv2d(in_channels=1,out_channels=32,kernel_size = 3),\n",
    "            nn.MaxPool2d(kernel_size = 2,stride = 2),\n",
    "            nn.Conv2d(in_channels=32,out_channels=64,kernel_size = 5),\n",
    "            nn.MaxPool2d(kernel_size = 2,stride = 2),\n",
    "            nn.Dropout2d(p = 0.1),\n",
    "            nn.AdaptiveMaxPool2d((1,1)),\n",
    "            nn.Flatten(),\n",
    "            nn.Linear(64,32),\n",
    "            nn.ReLU(),\n",
    "            nn.Linear(32,10)]\n",
    "        )\n",
    "    def forward(self,x):\n",
    "        for layer in self.layers:\n",
    "            x = layer(x)\n",
    "        return x\n",
    "net = Net()\n",
    "print(net)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "840dec1d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "6c97a606",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os,sys,time\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import datetime \n",
    "from tqdm import tqdm \n",
    "\n",
    "import torch\n",
    "from torch import nn \n",
    "from copy import deepcopy\n",
    "\n",
    "def printlog(info):\n",
    "    nowtime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')\n",
    "    print(\"\\n\"+\"==========\"*8 + \"%s\"%nowtime)\n",
    "    print(str(info)+\"\\n\")\n",
    "\n",
    "class StepRunner:\n",
    "    def __init__(self, net, loss_fn,\n",
    "                 stage = \"train\", metrics_dict = None, \n",
    "                 optimizer = None\n",
    "                 ):\n",
    "        self.net,self.loss_fn,self.metrics_dict,self.stage = net,loss_fn,metrics_dict,stage\n",
    "        self.optimizer = optimizer\n",
    "            \n",
    "    def step(self, features, labels):\n",
    "        #loss\n",
    "        preds = self.net(features)\n",
    "        loss = self.loss_fn(preds,labels)\n",
    "        \n",
    "        #backward()\n",
    "        if self.optimizer is not None and self.stage==\"train\": \n",
    "            loss.backward()\n",
    "            self.optimizer.step()\n",
    "            self.optimizer.zero_grad()\n",
    "            \n",
    "        #metrics\n",
    "        step_metrics = {self.stage+\"_\"+name:metric_fn(preds, labels).item() \n",
    "                        for name,metric_fn in self.metrics_dict.items()}\n",
    "        return loss.item(),step_metrics\n",
    "    \n",
    "    def train_step(self,features,labels):\n",
    "        self.net.train() #训练模式, dropout层发生作用\n",
    "        return self.step(features,labels)\n",
    "    \n",
    "    @torch.no_grad()\n",
    "    def eval_step(self,features,labels):\n",
    "        self.net.eval() #预测模式, dropout层不发生作用\n",
    "        return self.step(features,labels)\n",
    "    \n",
    "    def __call__(self,features,labels):\n",
    "        if self.stage==\"train\":\n",
    "            return self.train_step(features,labels) \n",
    "        else:\n",
    "            return self.eval_step(features,labels)\n",
    "        \n",
    "class EpochRunner:\n",
    "    def __init__(self,steprunner):\n",
    "        self.steprunner = steprunner\n",
    "        self.stage = steprunner.stage\n",
    "        \n",
    "    def __call__(self,dataloader):\n",
    "        total_loss,step = 0,0\n",
    "        loop = tqdm(enumerate(dataloader), total =len(dataloader))\n",
    "        for i, batch in loop: \n",
    "            loss, step_metrics = self.steprunner(*batch)\n",
    "            step_log = dict({self.stage+\"_loss\":loss},**step_metrics)\n",
    "            total_loss += loss\n",
    "            step+=1\n",
    "            if i!=len(dataloader)-1:\n",
    "                loop.set_postfix(**step_log)\n",
    "            else:\n",
    "                epoch_loss = total_loss/step\n",
    "                epoch_metrics = {self.stage+\"_\"+name:metric_fn.compute().item() \n",
    "                                 for name,metric_fn in self.steprunner.metrics_dict.items()}\n",
    "                epoch_log = dict({self.stage+\"_loss\":epoch_loss},**epoch_metrics)\n",
    "                loop.set_postfix(**epoch_log)\n",
    "\n",
    "                for name,metric_fn in self.steprunner.metrics_dict.items():\n",
    "                    metric_fn.reset()\n",
    "        return epoch_log\n",
    "\n",
    "\n",
    "def train_model(net, optimizer, loss_fn, metrics_dict, \n",
    "                train_data, val_data=None, \n",
    "                epochs=10, ckpt_path='checkpoint.pt',\n",
    "                patience=5, monitor=\"val_loss\", mode=\"min\"):\n",
    "    \n",
    "    history = {}\n",
    "\n",
    "    for epoch in range(1, epochs+1):\n",
    "        printlog(\"Epoch {0} / {1}\".format(epoch, epochs))\n",
    "\n",
    "        # 1，train -------------------------------------------------  \n",
    "        train_step_runner = StepRunner(net = net,stage=\"train\",\n",
    "                loss_fn = loss_fn,metrics_dict=deepcopy(metrics_dict),\n",
    "                optimizer = optimizer)\n",
    "        train_epoch_runner = EpochRunner(train_step_runner)\n",
    "        train_metrics = train_epoch_runner(train_data)\n",
    "\n",
    "        for name, metric in train_metrics.items():\n",
    "            history[name] = history.get(name, []) + [metric]\n",
    "\n",
    "        # 2，validate -------------------------------------------------\n",
    "        if val_data:\n",
    "            val_step_runner = StepRunner(net = net,stage=\"val\",\n",
    "                loss_fn = loss_fn,metrics_dict=deepcopy(metrics_dict))\n",
    "            val_epoch_runner = EpochRunner(val_step_runner)\n",
    "            with torch.no_grad():\n",
    "                val_metrics = val_epoch_runner(val_data)\n",
    "            val_metrics[\"epoch\"] = epoch\n",
    "            for name, metric in val_metrics.items():\n",
    "                history[name] = history.get(name, []) + [metric]\n",
    "\n",
    "        # 3，early-stopping -------------------------------------------------\n",
    "        arr_scores = history[monitor]\n",
    "        best_score_idx = np.argmax(arr_scores) if mode==\"max\" else np.argmin(arr_scores)\n",
    "        if best_score_idx==len(arr_scores)-1:\n",
    "            torch.save(net.state_dict(),ckpt_path)\n",
    "            print(\"<<<<<< reach best {0} : {1} >>>>>>\".format(monitor,\n",
    "                 arr_scores[best_score_idx]),file=sys.stderr)\n",
    "        if len(arr_scores)-best_score_idx>patience:\n",
    "            print(\"<<<<<< {} without improvement in {} epoch, early stopping >>>>>>\".format(\n",
    "                monitor,patience),file=sys.stderr)\n",
    "            break \n",
    "        net.load_state_dict(torch.load(ckpt_path))\n",
    "\n",
    "    return pd.DataFrame(history)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "feb456ac",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 16:58:14\n",
      "Epoch 1 / 10\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:22<00:00, 20.85it/s, train_acc=0.901, train_loss=0.304]\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 31.61it/s, val_acc=0.971, val_loss=0.0954]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 16:58:39\n",
      "Epoch 2 / 10\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "<<<<<< reach best val_acc : 0.97079998254776 >>>>>>\n",
      "100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:22<00:00, 21.04it/s, train_acc=0.966, train_loss=0.113]\n",
      "100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 31.05it/s, val_acc=0.98, val_loss=0.0678]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 16:59:04\n",
      "Epoch 3 / 10\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "<<<<<< reach best val_acc : 0.9801999926567078 >>>>>>\n",
      "100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:22<00:00, 20.99it/s, train_acc=0.971, train_loss=0.0969]\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 31.92it/s, val_acc=0.979, val_loss=0.0709]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 16:59:29\n",
      "Epoch 4 / 10\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:22<00:00, 20.74it/s, train_acc=0.97, train_loss=0.101]\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 29.90it/s, val_acc=0.981, val_loss=0.0652]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 16:59:54\n",
      "Epoch 5 / 10\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "<<<<<< reach best val_acc : 0.9811999797821045 >>>>>>\n",
      "100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:23<00:00, 20.27it/s, train_acc=0.975, train_loss=0.0832]\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 30.07it/s, val_acc=0.984, val_loss=0.0561]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 17:00:20\n",
      "Epoch 6 / 10\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "<<<<<< reach best val_acc : 0.9836000204086304 >>>>>>\n",
      "100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:23<00:00, 20.24it/s, train_acc=0.977, train_loss=0.0788]\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 29.13it/s, val_acc=0.981, val_loss=0.0756]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 17:00:46\n",
      "Epoch 7 / 10\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:22<00:00, 20.74it/s, train_acc=0.975, train_loss=0.0834]\n",
      "100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 31.43it/s, val_acc=0.98, val_loss=0.0824]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "================================================================================2023-08-02 17:01:11\n",
      "Epoch 8 / 10\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 469/469 [00:22<00:00, 20.53it/s, train_acc=0.975, train_loss=0.0828]\n",
      "100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 79/79 [00:02<00:00, 32.60it/s, val_acc=0.981, val_loss=0.0708]\n",
      "<<<<<< val_acc without improvement in 3 epoch, early stopping >>>>>>\n"
     ]
    }
   ],
   "source": [
    "from torchmetrics import Accuracy\n",
    "loss_fn = nn.CrossEntropyLoss()\n",
    "optimizer= torch.optim.Adam(net.parameters(),lr = 0.01)   \n",
    "metrics_dict = {\"acc\":Accuracy(task='multiclass',num_classes=10)}\n",
    "\n",
    "dfhistory = train_model(net,\n",
    "    optimizer,\n",
    "    loss_fn,\n",
    "    metrics_dict,\n",
    "    train_data = dl_train,\n",
    "    val_data= dl_val,\n",
    "    epochs=10,\n",
    "    patience=3,\n",
    "    monitor=\"val_acc\", \n",
    "    mode=\"max\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4bcd9c07",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d085b560",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "0b68de55",
   "metadata": {},
   "source": [
    "### 三，类风格"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "40c2c331",
   "metadata": {},
   "source": [
    "此处使用torchkeras.KerasModel高层次API接口中的fit方法训练模型。\n",
    "\n",
    "使用该形式训练模型非常简洁明了。\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "eab1d853",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Net(\n",
      "  (layers): ModuleList(\n",
      "    (0): Conv2d(1, 32, kernel_size=(3, 3), stride=(1, 1))\n",
      "    (1): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
      "    (2): Conv2d(32, 64, kernel_size=(5, 5), stride=(1, 1))\n",
      "    (3): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
      "    (4): Dropout2d(p=0.1, inplace=False)\n",
      "    (5): AdaptiveMaxPool2d(output_size=(1, 1))\n",
      "    (6): Flatten(start_dim=1, end_dim=-1)\n",
      "    (7): Linear(in_features=64, out_features=32, bias=True)\n",
      "    (8): ReLU()\n",
      "    (9): Linear(in_features=32, out_features=10, bias=True)\n",
      "  )\n",
      ")\n"
     ]
    }
   ],
   "source": [
    "from torchkeras import KerasModel \n",
    "\n",
    "class Net(nn.Module):\n",
    "    def __init__(self):\n",
    "        super().__init__()\n",
    "        self.layers = nn.ModuleList([\n",
    "            nn.Conv2d(in_channels=1,out_channels=32,kernel_size = 3),\n",
    "            nn.MaxPool2d(kernel_size = 2,stride = 2),\n",
    "            nn.Conv2d(in_channels=32,out_channels=64,kernel_size = 5),\n",
    "            nn.MaxPool2d(kernel_size = 2,stride = 2),\n",
    "            nn.Dropout2d(p = 0.1),\n",
    "            nn.AdaptiveMaxPool2d((1,1)),\n",
    "            nn.Flatten(),\n",
    "            nn.Linear(64,32),\n",
    "            nn.ReLU(),\n",
    "            nn.Linear(32,10)]\n",
    "        )\n",
    "    def forward(self,x):\n",
    "        for layer in self.layers:\n",
    "            x = layer(x)\n",
    "        return x\n",
    "    \n",
    "net = Net() \n",
    "\n",
    "print(net)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "cf6ae428",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[0;31m<<<<<< 🐌 cpu is used >>>>>>\u001b[0m\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"392.14375pt\" height=\"281.634375pt\" viewBox=\"0 0 392.14375 281.634375\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2023-08-02T17:06:30.867934</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.6.2, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 281.634375 \n",
       "L 392.14375 281.634375 \n",
       "L 392.14375 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 50.14375 244.078125 \n",
       "L 384.94375 244.078125 \n",
       "L 384.94375 22.318125 \n",
       "L 50.14375 22.318125 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <defs>\n",
       "       <path id=\"mc16f1025e6\" d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc16f1025e6\" x=\"65.361932\" y=\"244.078125\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 1 -->\n",
       "      <g transform=\"translate(62.180682 258.676562) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-31\" d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-31\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_2\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc16f1025e6\" x=\"103.407386\" y=\"244.078125\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 2 -->\n",
       "      <g transform=\"translate(100.226136 258.676562) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-32\" d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc16f1025e6\" x=\"141.452841\" y=\"244.078125\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 3 -->\n",
       "      <g transform=\"translate(138.271591 258.676562) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-33\" d=\"M 2597 2516 \n",
       "Q 3050 2419 3304 2112 \n",
       "Q 3559 1806 3559 1356 \n",
       "Q 3559 666 3084 287 \n",
       "Q 2609 -91 1734 -91 \n",
       "Q 1441 -91 1130 -33 \n",
       "Q 819 25 488 141 \n",
       "L 488 750 \n",
       "Q 750 597 1062 519 \n",
       "Q 1375 441 1716 441 \n",
       "Q 2309 441 2620 675 \n",
       "Q 2931 909 2931 1356 \n",
       "Q 2931 1769 2642 2001 \n",
       "Q 2353 2234 1838 2234 \n",
       "L 1294 2234 \n",
       "L 1294 2753 \n",
       "L 1863 2753 \n",
       "Q 2328 2753 2575 2939 \n",
       "Q 2822 3125 2822 3475 \n",
       "Q 2822 3834 2567 4026 \n",
       "Q 2313 4219 1838 4219 \n",
       "Q 1578 4219 1281 4162 \n",
       "Q 984 4106 628 3988 \n",
       "L 628 4550 \n",
       "Q 988 4650 1302 4700 \n",
       "Q 1616 4750 1894 4750 \n",
       "Q 2613 4750 3031 4423 \n",
       "Q 3450 4097 3450 3541 \n",
       "Q 3450 3153 3228 2886 \n",
       "Q 3006 2619 2597 2516 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-33\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc16f1025e6\" x=\"179.498295\" y=\"244.078125\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 4 -->\n",
       "      <g transform=\"translate(176.317045 258.676562) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-34\" d=\"M 2419 4116 \n",
       "L 825 1625 \n",
       "L 2419 1625 \n",
       "L 2419 4116 \n",
       "z\n",
       "M 2253 4666 \n",
       "L 3047 4666 \n",
       "L 3047 1625 \n",
       "L 3713 1625 \n",
       "L 3713 1100 \n",
       "L 3047 1100 \n",
       "L 3047 0 \n",
       "L 2419 0 \n",
       "L 2419 1100 \n",
       "L 313 1100 \n",
       "L 313 1709 \n",
       "L 2253 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-34\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc16f1025e6\" x=\"217.54375\" y=\"244.078125\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 5 -->\n",
       "      <g transform=\"translate(214.3625 258.676562) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-35\" d=\"M 691 4666 \n",
       "L 3169 4666 \n",
       "L 3169 4134 \n",
       "L 1269 4134 \n",
       "L 1269 2991 \n",
       "Q 1406 3038 1543 3061 \n",
       "Q 1681 3084 1819 3084 \n",
       "Q 2600 3084 3056 2656 \n",
       "Q 3513 2228 3513 1497 \n",
       "Q 3513 744 3044 326 \n",
       "Q 2575 -91 1722 -91 \n",
       "Q 1428 -91 1123 -41 \n",
       "Q 819 9 494 109 \n",
       "L 494 744 \n",
       "Q 775 591 1075 516 \n",
       "Q 1375 441 1709 441 \n",
       "Q 2250 441 2565 725 \n",
       "Q 2881 1009 2881 1497 \n",
       "Q 2881 1984 2565 2268 \n",
       "Q 2250 2553 1709 2553 \n",
       "Q 1456 2553 1204 2497 \n",
       "Q 953 2441 691 2322 \n",
       "L 691 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-35\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc16f1025e6\" x=\"255.589205\" y=\"244.078125\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 6 -->\n",
       "      <g transform=\"translate(252.407955 258.676562) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-36\" d=\"M 2113 2584 \n",
       "Q 1688 2584 1439 2293 \n",
       "Q 1191 2003 1191 1497 \n",
       "Q 1191 994 1439 701 \n",
       "Q 1688 409 2113 409 \n",
       "Q 2538 409 2786 701 \n",
       "Q 3034 994 3034 1497 \n",
       "Q 3034 2003 2786 2293 \n",
       "Q 2538 2584 2113 2584 \n",
       "z\n",
       "M 3366 4563 \n",
       "L 3366 3988 \n",
       "Q 3128 4100 2886 4159 \n",
       "Q 2644 4219 2406 4219 \n",
       "Q 1781 4219 1451 3797 \n",
       "Q 1122 3375 1075 2522 \n",
       "Q 1259 2794 1537 2939 \n",
       "Q 1816 3084 2150 3084 \n",
       "Q 2853 3084 3261 2657 \n",
       "Q 3669 2231 3669 1497 \n",
       "Q 3669 778 3244 343 \n",
       "Q 2819 -91 2113 -91 \n",
       "Q 1303 -91 875 529 \n",
       "Q 447 1150 447 2328 \n",
       "Q 447 3434 972 4092 \n",
       "Q 1497 4750 2381 4750 \n",
       "Q 2619 4750 2861 4703 \n",
       "Q 3103 4656 3366 4563 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-36\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc16f1025e6\" x=\"293.634659\" y=\"244.078125\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 7 -->\n",
       "      <g transform=\"translate(290.453409 258.676562) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-37\" d=\"M 525 4666 \n",
       "L 3525 4666 \n",
       "L 3525 4397 \n",
       "L 1831 0 \n",
       "L 1172 0 \n",
       "L 2766 4134 \n",
       "L 525 4134 \n",
       "L 525 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-37\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_8\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc16f1025e6\" x=\"331.680114\" y=\"244.078125\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 8 -->\n",
       "      <g transform=\"translate(328.498864 258.676562) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-38\" d=\"M 2034 2216 \n",
       "Q 1584 2216 1326 1975 \n",
       "Q 1069 1734 1069 1313 \n",
       "Q 1069 891 1326 650 \n",
       "Q 1584 409 2034 409 \n",
       "Q 2484 409 2743 651 \n",
       "Q 3003 894 3003 1313 \n",
       "Q 3003 1734 2745 1975 \n",
       "Q 2488 2216 2034 2216 \n",
       "z\n",
       "M 1403 2484 \n",
       "Q 997 2584 770 2862 \n",
       "Q 544 3141 544 3541 \n",
       "Q 544 4100 942 4425 \n",
       "Q 1341 4750 2034 4750 \n",
       "Q 2731 4750 3128 4425 \n",
       "Q 3525 4100 3525 3541 \n",
       "Q 3525 3141 3298 2862 \n",
       "Q 3072 2584 2669 2484 \n",
       "Q 3125 2378 3379 2068 \n",
       "Q 3634 1759 3634 1313 \n",
       "Q 3634 634 3220 271 \n",
       "Q 2806 -91 2034 -91 \n",
       "Q 1263 -91 848 271 \n",
       "Q 434 634 434 1313 \n",
       "Q 434 1759 690 2068 \n",
       "Q 947 2378 1403 2484 \n",
       "z\n",
       "M 1172 3481 \n",
       "Q 1172 3119 1398 2916 \n",
       "Q 1625 2713 2034 2713 \n",
       "Q 2441 2713 2670 2916 \n",
       "Q 2900 3119 2900 3481 \n",
       "Q 2900 3844 2670 4047 \n",
       "Q 2441 4250 2034 4250 \n",
       "Q 1625 4250 1398 4047 \n",
       "Q 1172 3844 1172 3481 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-38\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_9\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mc16f1025e6\" x=\"369.725568\" y=\"244.078125\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 9 -->\n",
       "      <g transform=\"translate(366.544318 258.676562) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-39\" d=\"M 703 97 \n",
       "L 703 672 \n",
       "Q 941 559 1184 500 \n",
       "Q 1428 441 1663 441 \n",
       "Q 2288 441 2617 861 \n",
       "Q 2947 1281 2994 2138 \n",
       "Q 2813 1869 2534 1725 \n",
       "Q 2256 1581 1919 1581 \n",
       "Q 1219 1581 811 2004 \n",
       "Q 403 2428 403 3163 \n",
       "Q 403 3881 828 4315 \n",
       "Q 1253 4750 1959 4750 \n",
       "Q 2769 4750 3195 4129 \n",
       "Q 3622 3509 3622 2328 \n",
       "Q 3622 1225 3098 567 \n",
       "Q 2575 -91 1691 -91 \n",
       "Q 1453 -91 1209 -44 \n",
       "Q 966 3 703 97 \n",
       "z\n",
       "M 1959 2075 \n",
       "Q 2384 2075 2632 2365 \n",
       "Q 2881 2656 2881 3163 \n",
       "Q 2881 3666 2632 3958 \n",
       "Q 2384 4250 1959 4250 \n",
       "Q 1534 4250 1286 3958 \n",
       "Q 1038 3666 1038 3163 \n",
       "Q 1038 2656 1286 2365 \n",
       "Q 1534 2075 1959 2075 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-39\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_10\">\n",
       "     <!-- epoch -->\n",
       "     <g transform=\"translate(202.315625 272.354687) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-65\" d=\"M 3597 1894 \n",
       "L 3597 1613 \n",
       "L 953 1613 \n",
       "Q 991 1019 1311 708 \n",
       "Q 1631 397 2203 397 \n",
       "Q 2534 397 2845 478 \n",
       "Q 3156 559 3463 722 \n",
       "L 3463 178 \n",
       "Q 3153 47 2828 -22 \n",
       "Q 2503 -91 2169 -91 \n",
       "Q 1331 -91 842 396 \n",
       "Q 353 884 353 1716 \n",
       "Q 353 2575 817 3079 \n",
       "Q 1281 3584 2069 3584 \n",
       "Q 2775 3584 3186 3129 \n",
       "Q 3597 2675 3597 1894 \n",
       "z\n",
       "M 3022 2063 \n",
       "Q 3016 2534 2758 2815 \n",
       "Q 2500 3097 2075 3097 \n",
       "Q 1594 3097 1305 2825 \n",
       "Q 1016 2553 972 2059 \n",
       "L 3022 2063 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-70\" d=\"M 1159 525 \n",
       "L 1159 -1331 \n",
       "L 581 -1331 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2969 \n",
       "Q 1341 3281 1617 3432 \n",
       "Q 1894 3584 2278 3584 \n",
       "Q 2916 3584 3314 3078 \n",
       "Q 3713 2572 3713 1747 \n",
       "Q 3713 922 3314 415 \n",
       "Q 2916 -91 2278 -91 \n",
       "Q 1894 -91 1617 61 \n",
       "Q 1341 213 1159 525 \n",
       "z\n",
       "M 3116 1747 \n",
       "Q 3116 2381 2855 2742 \n",
       "Q 2594 3103 2138 3103 \n",
       "Q 1681 3103 1420 2742 \n",
       "Q 1159 2381 1159 1747 \n",
       "Q 1159 1113 1420 752 \n",
       "Q 1681 391 2138 391 \n",
       "Q 2594 391 2855 752 \n",
       "Q 3116 1113 3116 1747 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-6f\" d=\"M 1959 3097 \n",
       "Q 1497 3097 1228 2736 \n",
       "Q 959 2375 959 1747 \n",
       "Q 959 1119 1226 758 \n",
       "Q 1494 397 1959 397 \n",
       "Q 2419 397 2687 759 \n",
       "Q 2956 1122 2956 1747 \n",
       "Q 2956 2369 2687 2733 \n",
       "Q 2419 3097 1959 3097 \n",
       "z\n",
       "M 1959 3584 \n",
       "Q 2709 3584 3137 3096 \n",
       "Q 3566 2609 3566 1747 \n",
       "Q 3566 888 3137 398 \n",
       "Q 2709 -91 1959 -91 \n",
       "Q 1206 -91 779 398 \n",
       "Q 353 888 353 1747 \n",
       "Q 353 2609 779 3096 \n",
       "Q 1206 3584 1959 3584 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-63\" d=\"M 3122 3366 \n",
       "L 3122 2828 \n",
       "Q 2878 2963 2633 3030 \n",
       "Q 2388 3097 2138 3097 \n",
       "Q 1578 3097 1268 2742 \n",
       "Q 959 2388 959 1747 \n",
       "Q 959 1106 1268 751 \n",
       "Q 1578 397 2138 397 \n",
       "Q 2388 397 2633 464 \n",
       "Q 2878 531 3122 666 \n",
       "L 3122 134 \n",
       "Q 2881 22 2623 -34 \n",
       "Q 2366 -91 2075 -91 \n",
       "Q 1284 -91 818 406 \n",
       "Q 353 903 353 1747 \n",
       "Q 353 2603 823 3093 \n",
       "Q 1294 3584 2113 3584 \n",
       "Q 2378 3584 2631 3529 \n",
       "Q 2884 3475 3122 3366 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-68\" d=\"M 3513 2113 \n",
       "L 3513 0 \n",
       "L 2938 0 \n",
       "L 2938 2094 \n",
       "Q 2938 2591 2744 2837 \n",
       "Q 2550 3084 2163 3084 \n",
       "Q 1697 3084 1428 2787 \n",
       "Q 1159 2491 1159 1978 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 4863 \n",
       "L 1159 4863 \n",
       "L 1159 2956 \n",
       "Q 1366 3272 1645 3428 \n",
       "Q 1925 3584 2291 3584 \n",
       "Q 2894 3584 3203 3211 \n",
       "Q 3513 2838 3513 2113 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-65\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-70\" x=\"61.523438\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6f\" x=\"125\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"186.181641\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-68\" x=\"241.162109\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_10\">\n",
       "      <defs>\n",
       "       <path id=\"m242689a4c8\" d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#m242689a4c8\" x=\"50.14375\" y=\"232.51369\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 0.88 -->\n",
       "      <g transform=\"translate(20.878125 236.312909) scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-2e\" d=\"M 684 794 \n",
       "L 1344 794 \n",
       "L 1344 0 \n",
       "L 684 0 \n",
       "L 684 794 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-38\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-38\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m242689a4c8\" x=\"50.14375\" y=\"194.613013\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 0.90 -->\n",
       "      <g transform=\"translate(20.878125 198.412232) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-39\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_12\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m242689a4c8\" x=\"50.14375\" y=\"156.712336\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_13\">\n",
       "      <!-- 0.92 -->\n",
       "      <g transform=\"translate(20.878125 160.511555) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-39\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m242689a4c8\" x=\"50.14375\" y=\"118.811659\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_14\">\n",
       "      <!-- 0.94 -->\n",
       "      <g transform=\"translate(20.878125 122.610877) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-39\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_14\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m242689a4c8\" x=\"50.14375\" y=\"80.910982\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_15\">\n",
       "      <!-- 0.96 -->\n",
       "      <g transform=\"translate(20.878125 84.7102) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-39\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-36\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m242689a4c8\" x=\"50.14375\" y=\"43.010304\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_16\">\n",
       "      <!-- 0.98 -->\n",
       "      <g transform=\"translate(20.878125 46.809523) scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-39\" x=\"95.410156\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-38\" x=\"159.033203\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_17\">\n",
       "     <!-- acc -->\n",
       "     <g transform=\"translate(14.798438 141.760625) rotate(-90) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-61\" d=\"M 2194 1759 \n",
       "Q 1497 1759 1228 1600 \n",
       "Q 959 1441 959 1056 \n",
       "Q 959 750 1161 570 \n",
       "Q 1363 391 1709 391 \n",
       "Q 2188 391 2477 730 \n",
       "Q 2766 1069 2766 1631 \n",
       "L 2766 1759 \n",
       "L 2194 1759 \n",
       "z\n",
       "M 3341 1997 \n",
       "L 3341 0 \n",
       "L 2766 0 \n",
       "L 2766 531 \n",
       "Q 2569 213 2275 61 \n",
       "Q 1981 -91 1556 -91 \n",
       "Q 1019 -91 701 211 \n",
       "Q 384 513 384 1019 \n",
       "Q 384 1609 779 1909 \n",
       "Q 1175 2209 1959 2209 \n",
       "L 2766 2209 \n",
       "L 2766 2266 \n",
       "Q 2766 2663 2505 2880 \n",
       "Q 2244 3097 1772 3097 \n",
       "Q 1472 3097 1187 3025 \n",
       "Q 903 2953 641 2809 \n",
       "L 641 3341 \n",
       "Q 956 3463 1253 3523 \n",
       "Q 1550 3584 1831 3584 \n",
       "Q 2591 3584 2966 3190 \n",
       "Q 3341 2797 3341 1997 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-61\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"61.279297\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"116.259766\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_16\">\n",
       "    <path d=\"M 65.361932 233.998125 \n",
       "L 103.407386 74.183665 \n",
       "L 141.452841 60.665698 \n",
       "L 179.498295 55.359626 \n",
       "L 217.54375 51.980078 \n",
       "L 255.589205 47.842616 \n",
       "L 293.634659 44.621088 \n",
       "L 331.680114 41.367934 \n",
       "L 369.725568 42.252242 \n",
       "\" style=\"fill: none; stroke-dasharray: 5.55,2.4; stroke-dashoffset: 0; stroke: #0000ff; stroke-width: 1.5\"/>\n",
       "    <defs>\n",
       "     <path id=\"m0cab77cee5\" d=\"M 0 3 \n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
       "C 2.683901 1.55874 3 0.795609 3 0 \n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \n",
       "z\n",
       "\" style=\"stroke: #0000ff\"/>\n",
       "    </defs>\n",
       "    <g>\n",
       "     <use xlink:href=\"#m0cab77cee5\" x=\"65.361932\" y=\"233.998125\" style=\"fill: #0000ff; stroke: #0000ff\"/>\n",
       "     <use xlink:href=\"#m0cab77cee5\" x=\"103.407386\" y=\"74.183665\" style=\"fill: #0000ff; stroke: #0000ff\"/>\n",
       "     <use xlink:href=\"#m0cab77cee5\" x=\"141.452841\" y=\"60.665698\" style=\"fill: #0000ff; stroke: #0000ff\"/>\n",
       "     <use xlink:href=\"#m0cab77cee5\" x=\"179.498295\" y=\"55.359626\" style=\"fill: #0000ff; stroke: #0000ff\"/>\n",
       "     <use xlink:href=\"#m0cab77cee5\" x=\"217.54375\" y=\"51.980078\" style=\"fill: #0000ff; stroke: #0000ff\"/>\n",
       "     <use xlink:href=\"#m0cab77cee5\" x=\"255.589205\" y=\"47.842616\" style=\"fill: #0000ff; stroke: #0000ff\"/>\n",
       "     <use xlink:href=\"#m0cab77cee5\" x=\"293.634659\" y=\"44.621088\" style=\"fill: #0000ff; stroke: #0000ff\"/>\n",
       "     <use xlink:href=\"#m0cab77cee5\" x=\"331.680114\" y=\"41.367934\" style=\"fill: #0000ff; stroke: #0000ff\"/>\n",
       "     <use xlink:href=\"#m0cab77cee5\" x=\"369.725568\" y=\"42.252242\" style=\"fill: #0000ff; stroke: #0000ff\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_17\">\n",
       "    <path d=\"M 65.361932 85.459068 \n",
       "L 103.407386 47.937383 \n",
       "L 141.452841 40.357232 \n",
       "L 179.498295 46.610865 \n",
       "L 217.54375 41.494329 \n",
       "L 255.589205 32.398125 \n",
       "L 293.634659 42.441777 \n",
       "L 331.680114 46.8004 \n",
       "L 369.725568 37.893731 \n",
       "\" style=\"fill: none; stroke: #00bfbf; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "    <defs>\n",
       "     <path id=\"m25add76602\" d=\"M 0 3 \n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
       "C 2.683901 1.55874 3 0.795609 3 0 \n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \n",
       "z\n",
       "\" style=\"stroke: #00bfbf\"/>\n",
       "    </defs>\n",
       "    <g>\n",
       "     <use xlink:href=\"#m25add76602\" x=\"65.361932\" y=\"85.459068\" style=\"fill: #00bfbf; stroke: #00bfbf\"/>\n",
       "     <use xlink:href=\"#m25add76602\" x=\"103.407386\" y=\"47.937383\" style=\"fill: #00bfbf; stroke: #00bfbf\"/>\n",
       "     <use xlink:href=\"#m25add76602\" x=\"141.452841\" y=\"40.357232\" style=\"fill: #00bfbf; stroke: #00bfbf\"/>\n",
       "     <use xlink:href=\"#m25add76602\" x=\"179.498295\" y=\"46.610865\" style=\"fill: #00bfbf; stroke: #00bfbf\"/>\n",
       "     <use xlink:href=\"#m25add76602\" x=\"217.54375\" y=\"41.494329\" style=\"fill: #00bfbf; stroke: #00bfbf\"/>\n",
       "     <use xlink:href=\"#m25add76602\" x=\"255.589205\" y=\"32.398125\" style=\"fill: #00bfbf; stroke: #00bfbf\"/>\n",
       "     <use xlink:href=\"#m25add76602\" x=\"293.634659\" y=\"42.441777\" style=\"fill: #00bfbf; stroke: #00bfbf\"/>\n",
       "     <use xlink:href=\"#m25add76602\" x=\"331.680114\" y=\"46.8004\" style=\"fill: #00bfbf; stroke: #00bfbf\"/>\n",
       "     <use xlink:href=\"#m25add76602\" x=\"369.725568\" y=\"37.893731\" style=\"fill: #00bfbf; stroke: #00bfbf\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_18\">\n",
       "    <defs>\n",
       "     <path id=\"m31cee82f93\" d=\"M 0 -7.5 \n",
       "L -1.683855 -2.317627 \n",
       "L -7.132924 -2.317627 \n",
       "L -2.724534 0.885255 \n",
       "L -4.408389 6.067627 \n",
       "L -0 2.864745 \n",
       "L 4.408389 6.067627 \n",
       "L 2.724534 0.885255 \n",
       "L 7.132924 -2.317627 \n",
       "L 1.683855 -2.317627 \n",
       "z\n",
       "\" style=\"stroke: #ff0000; stroke-linejoin: bevel\"/>\n",
       "    </defs>\n",
       "    <g>\n",
       "     <use xlink:href=\"#m31cee82f93\" x=\"255.589205\" y=\"32.398125\" style=\"fill: #ff0000; stroke: #ff0000; stroke-linejoin: bevel\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 50.14375 244.078125 \n",
       "L 50.14375 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 384.94375 244.078125 \n",
       "L 384.94375 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 50.14375 244.078125 \n",
       "L 384.94375 244.078125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 50.14375 22.318125 \n",
       "L 384.94375 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_18\">\n",
       "    <!-- best val_acc=0.9856 (@epoch 6) -->\n",
       "    <g transform=\"translate(117.879063 16.318125) scale(0.12 -0.12)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-62\" d=\"M 3116 1747 \n",
       "Q 3116 2381 2855 2742 \n",
       "Q 2594 3103 2138 3103 \n",
       "Q 1681 3103 1420 2742 \n",
       "Q 1159 2381 1159 1747 \n",
       "Q 1159 1113 1420 752 \n",
       "Q 1681 391 2138 391 \n",
       "Q 2594 391 2855 752 \n",
       "Q 3116 1113 3116 1747 \n",
       "z\n",
       "M 1159 2969 \n",
       "Q 1341 3281 1617 3432 \n",
       "Q 1894 3584 2278 3584 \n",
       "Q 2916 3584 3314 3078 \n",
       "Q 3713 2572 3713 1747 \n",
       "Q 3713 922 3314 415 \n",
       "Q 2916 -91 2278 -91 \n",
       "Q 1894 -91 1617 61 \n",
       "Q 1341 213 1159 525 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 4863 \n",
       "L 1159 4863 \n",
       "L 1159 2969 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-73\" d=\"M 2834 3397 \n",
       "L 2834 2853 \n",
       "Q 2591 2978 2328 3040 \n",
       "Q 2066 3103 1784 3103 \n",
       "Q 1356 3103 1142 2972 \n",
       "Q 928 2841 928 2578 \n",
       "Q 928 2378 1081 2264 \n",
       "Q 1234 2150 1697 2047 \n",
       "L 1894 2003 \n",
       "Q 2506 1872 2764 1633 \n",
       "Q 3022 1394 3022 966 \n",
       "Q 3022 478 2636 193 \n",
       "Q 2250 -91 1575 -91 \n",
       "Q 1294 -91 989 -36 \n",
       "Q 684 19 347 128 \n",
       "L 347 722 \n",
       "Q 666 556 975 473 \n",
       "Q 1284 391 1588 391 \n",
       "Q 1994 391 2212 530 \n",
       "Q 2431 669 2431 922 \n",
       "Q 2431 1156 2273 1281 \n",
       "Q 2116 1406 1581 1522 \n",
       "L 1381 1569 \n",
       "Q 847 1681 609 1914 \n",
       "Q 372 2147 372 2553 \n",
       "Q 372 3047 722 3315 \n",
       "Q 1072 3584 1716 3584 \n",
       "Q 2034 3584 2315 3537 \n",
       "Q 2597 3491 2834 3397 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-74\" d=\"M 1172 4494 \n",
       "L 1172 3500 \n",
       "L 2356 3500 \n",
       "L 2356 3053 \n",
       "L 1172 3053 \n",
       "L 1172 1153 \n",
       "Q 1172 725 1289 603 \n",
       "Q 1406 481 1766 481 \n",
       "L 2356 481 \n",
       "L 2356 0 \n",
       "L 1766 0 \n",
       "Q 1100 0 847 248 \n",
       "Q 594 497 594 1153 \n",
       "L 594 3053 \n",
       "L 172 3053 \n",
       "L 172 3500 \n",
       "L 594 3500 \n",
       "L 594 4494 \n",
       "L 1172 4494 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-20\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-76\" d=\"M 191 3500 \n",
       "L 800 3500 \n",
       "L 1894 563 \n",
       "L 2988 3500 \n",
       "L 3597 3500 \n",
       "L 2284 0 \n",
       "L 1503 0 \n",
       "L 191 3500 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-6c\" d=\"M 603 4863 \n",
       "L 1178 4863 \n",
       "L 1178 0 \n",
       "L 603 0 \n",
       "L 603 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-5f\" d=\"M 3263 -1063 \n",
       "L 3263 -1509 \n",
       "L -63 -1509 \n",
       "L -63 -1063 \n",
       "L 3263 -1063 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-3d\" d=\"M 678 2906 \n",
       "L 4684 2906 \n",
       "L 4684 2381 \n",
       "L 678 2381 \n",
       "L 678 2906 \n",
       "z\n",
       "M 678 1631 \n",
       "L 4684 1631 \n",
       "L 4684 1100 \n",
       "L 678 1100 \n",
       "L 678 1631 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-28\" d=\"M 1984 4856 \n",
       "Q 1566 4138 1362 3434 \n",
       "Q 1159 2731 1159 2009 \n",
       "Q 1159 1288 1364 580 \n",
       "Q 1569 -128 1984 -844 \n",
       "L 1484 -844 \n",
       "Q 1016 -109 783 600 \n",
       "Q 550 1309 550 2009 \n",
       "Q 550 2706 781 3412 \n",
       "Q 1013 4119 1484 4856 \n",
       "L 1984 4856 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-40\" d=\"M 2381 1678 \n",
       "Q 2381 1231 2603 976 \n",
       "Q 2825 722 3213 722 \n",
       "Q 3597 722 3817 978 \n",
       "Q 4038 1234 4038 1678 \n",
       "Q 4038 2116 3813 2373 \n",
       "Q 3588 2631 3206 2631 \n",
       "Q 2828 2631 2604 2375 \n",
       "Q 2381 2119 2381 1678 \n",
       "z\n",
       "M 4084 744 \n",
       "Q 3897 503 3655 389 \n",
       "Q 3413 275 3091 275 \n",
       "Q 2553 275 2217 664 \n",
       "Q 1881 1053 1881 1678 \n",
       "Q 1881 2303 2218 2693 \n",
       "Q 2556 3084 3091 3084 \n",
       "Q 3413 3084 3656 2967 \n",
       "Q 3900 2850 4084 2613 \n",
       "L 4084 3022 \n",
       "L 4531 3022 \n",
       "L 4531 722 \n",
       "Q 4988 791 5245 1139 \n",
       "Q 5503 1488 5503 2041 \n",
       "Q 5503 2375 5404 2669 \n",
       "Q 5306 2963 5106 3213 \n",
       "Q 4781 3622 4314 3839 \n",
       "Q 3847 4056 3297 4056 \n",
       "Q 2913 4056 2559 3954 \n",
       "Q 2206 3853 1906 3653 \n",
       "Q 1416 3334 1139 2817 \n",
       "Q 863 2300 863 1697 \n",
       "Q 863 1200 1042 765 \n",
       "Q 1222 331 1563 0 \n",
       "Q 1891 -325 2322 -495 \n",
       "Q 2753 -666 3244 -666 \n",
       "Q 3647 -666 4036 -530 \n",
       "Q 4425 -394 4750 -141 \n",
       "L 5031 -488 \n",
       "Q 4641 -791 4180 -952 \n",
       "Q 3719 -1113 3244 -1113 \n",
       "Q 2666 -1113 2153 -908 \n",
       "Q 1641 -703 1241 -313 \n",
       "Q 841 78 631 592 \n",
       "Q 422 1106 422 1697 \n",
       "Q 422 2266 634 2781 \n",
       "Q 847 3297 1241 3688 \n",
       "Q 1644 4084 2172 4295 \n",
       "Q 2700 4506 3291 4506 \n",
       "Q 3953 4506 4520 4234 \n",
       "Q 5088 3963 5472 3463 \n",
       "Q 5706 3156 5829 2797 \n",
       "Q 5953 2438 5953 2053 \n",
       "Q 5953 1231 5456 756 \n",
       "Q 4959 281 4084 263 \n",
       "L 4084 744 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-29\" d=\"M 513 4856 \n",
       "L 1013 4856 \n",
       "Q 1481 4119 1714 3412 \n",
       "Q 1947 2706 1947 2009 \n",
       "Q 1947 1309 1714 600 \n",
       "Q 1481 -109 1013 -844 \n",
       "L 513 -844 \n",
       "Q 928 -128 1133 580 \n",
       "Q 1338 1288 1338 2009 \n",
       "Q 1338 2731 1133 3434 \n",
       "Q 928 4138 513 4856 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-62\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" x=\"63.476562\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-73\" x=\"125\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-74\" x=\"177.099609\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"216.308594\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-76\" x=\"248.095703\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-61\" x=\"307.275391\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\" x=\"368.554688\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-5f\" x=\"396.337891\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-61\" x=\"446.337891\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-63\" x=\"507.617188\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-63\" x=\"562.597656\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-3d\" x=\"617.578125\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-30\" x=\"701.367188\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" x=\"764.990234\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-39\" x=\"796.777344\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-38\" x=\"860.400391\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-35\" x=\"924.023438\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-36\" x=\"987.646484\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"1051.269531\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-28\" x=\"1083.056641\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-40\" x=\"1122.070312\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" x=\"1222.070312\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-70\" x=\"1283.59375\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6f\" x=\"1347.070312\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-63\" x=\"1408.251953\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-68\" x=\"1463.232422\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"1526.611328\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-36\" x=\"1558.398438\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-29\" x=\"1622.021484\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"legend_1\">\n",
       "    <g id=\"patch_7\">\n",
       "     <path d=\"M 300.54375 239.078125 \n",
       "L 377.94375 239.078125 \n",
       "Q 379.94375 239.078125 379.94375 237.078125 \n",
       "L 379.94375 208.165625 \n",
       "Q 379.94375 206.165625 377.94375 206.165625 \n",
       "L 300.54375 206.165625 \n",
       "Q 298.54375 206.165625 298.54375 208.165625 \n",
       "L 298.54375 237.078125 \n",
       "Q 298.54375 239.078125 300.54375 239.078125 \n",
       "z\n",
       "\" style=\"fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_19\">\n",
       "     <path d=\"M 302.54375 214.264062 \n",
       "L 312.54375 214.264062 \n",
       "L 322.54375 214.264062 \n",
       "\" style=\"fill: none; stroke-dasharray: 5.55,2.4; stroke-dashoffset: 0; stroke: #0000ff; stroke-width: 1.5\"/>\n",
       "     <g>\n",
       "      <use xlink:href=\"#m0cab77cee5\" x=\"312.54375\" y=\"214.264062\" style=\"fill: #0000ff; stroke: #0000ff\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_19\">\n",
       "     <!-- train_acc -->\n",
       "     <g transform=\"translate(330.54375 217.764062) scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-72\" d=\"M 2631 2963 \n",
       "Q 2534 3019 2420 3045 \n",
       "Q 2306 3072 2169 3072 \n",
       "Q 1681 3072 1420 2755 \n",
       "Q 1159 2438 1159 1844 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2956 \n",
       "Q 1341 3275 1631 3429 \n",
       "Q 1922 3584 2338 3584 \n",
       "Q 2397 3584 2469 3576 \n",
       "Q 2541 3569 2628 3553 \n",
       "L 2631 2963 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-69\" d=\"M 603 3500 \n",
       "L 1178 3500 \n",
       "L 1178 0 \n",
       "L 603 0 \n",
       "L 603 3500 \n",
       "z\n",
       "M 603 4863 \n",
       "L 1178 4863 \n",
       "L 1178 4134 \n",
       "L 603 4134 \n",
       "L 603 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-6e\" d=\"M 3513 2113 \n",
       "L 3513 0 \n",
       "L 2938 0 \n",
       "L 2938 2094 \n",
       "Q 2938 2591 2744 2837 \n",
       "Q 2550 3084 2163 3084 \n",
       "Q 1697 3084 1428 2787 \n",
       "Q 1159 2491 1159 1978 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2956 \n",
       "Q 1366 3272 1645 3428 \n",
       "Q 1925 3584 2291 3584 \n",
       "Q 2894 3584 3203 3211 \n",
       "Q 3513 2838 3513 2113 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-74\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-72\" x=\"39.208984\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" x=\"80.322266\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-69\" x=\"141.601562\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6e\" x=\"169.384766\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-5f\" x=\"232.763672\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" x=\"282.763672\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"344.042969\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"399.023438\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"line2d_20\">\n",
       "     <path d=\"M 302.54375 229.220312 \n",
       "L 312.54375 229.220312 \n",
       "L 322.54375 229.220312 \n",
       "\" style=\"fill: none; stroke: #00bfbf; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "     <g>\n",
       "      <use xlink:href=\"#m25add76602\" x=\"312.54375\" y=\"229.220312\" style=\"fill: #00bfbf; stroke: #00bfbf\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_20\">\n",
       "     <!-- val_acc -->\n",
       "     <g transform=\"translate(330.54375 232.720312) scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSans-76\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" x=\"59.179688\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6c\" x=\"120.458984\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-5f\" x=\"148.242188\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-61\" x=\"198.242188\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"259.521484\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-63\" x=\"314.501953\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 600x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<style>\n",
       "    /* background: */\n",
       "    progress::-webkit-progress-bar {background-color: #CDCDCD; width: 100%;}\n",
       "    progress {background-color: #CDCDCD;}\n",
       "\n",
       "    /* value: */\n",
       "    progress::-webkit-progress-value {background-color: #00BFFF  !important;}\n",
       "    progress::-moz-progress-bar {background-color: #00BFFF  !important;}\n",
       "    progress {color: #00BFFF ;}\n",
       "\n",
       "    /* optional */\n",
       "    .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
       "        background: #000000;\n",
       "    }\n",
       "</style>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "    <div>\n",
       "      <progress value='9' class='progress-bar-interrupted' max='10' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
       "      90.00% [9/10] [03:48<00:25]\n",
       "      <br>\n",
       "      ████████████████████100.00% [79/79] [val_loss=0.0678, val_acc=0.9827]\n",
       "    </div>\n",
       "    "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[0;31m<<<<<< val_acc without improvement in 3 epoch,early stopping >>>>>> \n",
      "\u001b[0m\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>epoch</th>\n",
       "      <th>train_loss</th>\n",
       "      <th>train_acc</th>\n",
       "      <th>lr</th>\n",
       "      <th>val_loss</th>\n",
       "      <th>val_acc</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0.368690</td>\n",
       "      <td>0.879217</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.140836</td>\n",
       "      <td>0.9576</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>0.120357</td>\n",
       "      <td>0.963550</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.082137</td>\n",
       "      <td>0.9774</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>0.099694</td>\n",
       "      <td>0.970683</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.063654</td>\n",
       "      <td>0.9814</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>0.088144</td>\n",
       "      <td>0.973483</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.078626</td>\n",
       "      <td>0.9781</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>0.084775</td>\n",
       "      <td>0.975267</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.071385</td>\n",
       "      <td>0.9808</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>0.080502</td>\n",
       "      <td>0.977450</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.051128</td>\n",
       "      <td>0.9856</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>0.076512</td>\n",
       "      <td>0.979150</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.072639</td>\n",
       "      <td>0.9803</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>0.067980</td>\n",
       "      <td>0.980867</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.090525</td>\n",
       "      <td>0.9780</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>0.073843</td>\n",
       "      <td>0.980400</td>\n",
       "      <td>0.01</td>\n",
       "      <td>0.067765</td>\n",
       "      <td>0.9827</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   epoch  train_loss  train_acc    lr  val_loss  val_acc\n",
       "0      1    0.368690   0.879217  0.01  0.140836   0.9576\n",
       "1      2    0.120357   0.963550  0.01  0.082137   0.9774\n",
       "2      3    0.099694   0.970683  0.01  0.063654   0.9814\n",
       "3      4    0.088144   0.973483  0.01  0.078626   0.9781\n",
       "4      5    0.084775   0.975267  0.01  0.071385   0.9808\n",
       "5      6    0.080502   0.977450  0.01  0.051128   0.9856\n",
       "6      7    0.076512   0.979150  0.01  0.072639   0.9803\n",
       "7      8    0.067980   0.980867  0.01  0.090525   0.9780\n",
       "8      9    0.073843   0.980400  0.01  0.067765   0.9827"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from torchmetrics import Accuracy\n",
    "\n",
    "model = KerasModel(net,\n",
    "                   loss_fn=nn.CrossEntropyLoss(),\n",
    "                   metrics_dict = {\"acc\":Accuracy(task='multiclass',num_classes=10)},\n",
    "                   optimizer = torch.optim.Adam(net.parameters(),lr = 0.01)  )\n",
    "\n",
    "model.fit(\n",
    "    train_data = dl_train,\n",
    "    val_data= dl_val,\n",
    "    epochs=10,\n",
    "    patience=3,\n",
    "    monitor=\"val_acc\", \n",
    "    mode=\"max\",\n",
    "    plot=True,\n",
    "    cpu=True\n",
    ")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "24d8c747",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "597ea3df",
   "metadata": {},
   "source": [
    "**如果本书对你有所帮助，想鼓励一下作者，记得给本项目加一颗星星star⭐️，并分享给你的朋友们喔😊!** \n",
    "\n",
    "如果对本书内容理解上有需要进一步和作者交流的地方，欢迎在公众号\"算法美食屋\"下留言。作者时间和精力有限，会酌情予以回复。\n",
    "\n",
    "也可以在公众号后台回复关键字：**加群**，加入读者交流群和大家讨论。\n",
    "\n",
    "![算法美食屋logo.png](https://tva1.sinaimg.cn/large/e6c9d24egy1h41m2zugguj20k00b9q46.jpg)"
   ]
  }
 ],
 "metadata": {
  "jupytext": {
   "cell_metadata_filter": "-all",
   "formats": "ipynb,md"
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
